Windows 10 (x64)
我想在Bazel中使用Haskell (2.0.0)。我在Windows 10 (x64)计算机上执行了以下步骤:
git clone https://github.com/tweag/rules_haskell/
cd rules_haskell
cd tutorial
bazel build //...这将产生以下结果:
INFO: Call stack for the definition of repository 'rules_haskell_ghc_windows_amd64' which is a _ghc_bindist (rule definition at C:/users/verte/_bazel_verte/idi6e53f/external/rules_haskell/haskell/ghc_bindist.bzl:289:16):
- C:/users/verte/_bazel_verte/idi6e53f/external/rules_haskell/haskell/ghc_bindist.bzl:409:5
- C:/users/verte/_bazel_verte/idi6e53f/external/rules_haskell/haskell/ghc_bindist.bzl:445:9
- C:/users/verte/_bazel_verte/idi6e53f/external/rules_haskell/haskell/toolchain.bzl:320:5
- D:/dev/rules_haskell/tutorial/WORKSPACE:22:1
ERROR: An error occurred during the fetch of repository 'rules_haskell_ghc_windows_amd64':
Traceback (most recent call last):
File "C:/users/verte/_bazel_verte/idi6e53f/external/rules_haskell/haskell/ghc_bindist.bzl", line 194
_find_python(ctx)
File "C:/users/verte/_bazel_verte/idi6e53f/external/rules_haskell/haskell/ghc_bindist.bzl", line 461, in _find_python
repository_ctx.execute(<1 more arguments>)
Argument 0 of execute is neither a path nor a string.
ERROR: D:/dev/rules_haskell/tutorial/lib/BUILD.bazel:6:1: //lib:booleans depends on @rules_haskell_ghc_windows_amd64//:toolchain-impl in repository @rules_haskell_ghc_windows_amd64 which failed to fetch. no such package '@rules_haskell_ghc_windows_amd64//': Traceback (most recent call last):
File "C:/users/verte/_bazel_verte/idi6e53f/external/rules_haskell/haskell/ghc_bindist.bzl", line 194
_find_python(ctx)
File "C:/users/verte/_bazel_verte/idi6e53f/external/rules_haskell/haskell/ghc_bindist.bzl", line 461, in _find_python
repository_ctx.execute(<1 more arguments>)
Argument 0 of execute is neither a path nor a string.
ERROR: Analysis of target '//lib:booleans' failed; build aborted: no such package '@rules_haskell_ghc_windows_amd64//': Traceback (most recent call last):
File "C:/users/verte/_bazel_verte/idi6e53f/external/rules_haskell/haskell/ghc_bindist.bzl", line 194
_find_python(ctx)
File "C:/users/verte/_bazel_verte/idi6e53f/external/rules_haskell/haskell/ghc_bindist.bzl", line 461, in _find_python
repository_ctx.execute(<1 more arguments>)
Argument 0 of execute is neither a path nor a string.
INFO: Elapsed time: 11.900s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (27 packages loaded, 44 targets configured)我安装了msys2和python3 (Vesion 3.7.6),就像描述的这里一样。
该错误似乎发生在_find_python中。My变量($Env:Path)包含python.exe的路径。
有人成功地在Windows 10上构建本教程吗?
这天蓝色管道似乎可以在Windows上构建Haskell规则:
要使这一工作发挥作用,似乎需要两个步骤:
步骤1 (Powershell):
Write-Host "Enable long path behavior"
# See https://learn.microsoft.com/en-us/windows/desktop/fileio/naming-a-file#maximum-path-length-limitation
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1 displayName: "Enable da long paths"步骤2 (bash):
# Remove 'C:\Program Files ' (ending on space) from PATH.
# See https://github.com/bazelbuild/bazel/issues/10481
export PATH="$(sed 's,:/c/Program Files $,,' <<<"$PATH")"
echo "PATH='$PATH'"我不知道如何在(本地) Windows 10机器上复制这种情况
Ubuntu18.04
git clone https://github.com/tweag/rules_haskell/
cd rules_haskell
cd tutorial
bazel build //...这将产生以下结果:
INFO: Analyzed 3 targets (0 packages loaded, 0 targets configured).
INFO: Found 3 targets...
ERROR: /home/newton/dev/rules_haskell/tutorial/lib/BUILD.bazel:6:1: HaskellLinkDynamicLibrary lib/libHSlibZSbooleans-ghc8.6.5.so failed (Exit 1) ghc_wrapper failed: error executing command bazel-out/host/bin/external/rules_haskell/haskell/ghc_wrapper bazel-out/k8-fastbuild/bin/lib/compile_flags_booleans_HaskellLinkDynamicLibrary ... (remaining 1 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
/usr/bin/ld.gold: error: cannot find -lgmp
collect2: error: ld returned 1 exit status
`cc_wrapper-python' failed in phase `Linker'. (Exit code: 1)
INFO: Elapsed time: 0.554s, Critical Path: 0.37s
INFO: 0 processes.
FAILED: Build did NOT complete successfully使用Ubuntu (BazelVersion2.0.0)而不是Windows构建教程也不适合我。有什么暗示吗?
发布于 2020-01-09 19:19:11
Ubuntu18.04的解决方案
通过安装以下软件包解决了Ubuntu上的构建问题:
sudo apt-get install build-essential libffi-dev libgmp-dev libtinfo5 libtinfo-dev python python3Windows 10 x64
安装了Visual 2019时出现了问题。通过重写cc_toolchain,可以修复以下问题:
bazel run --crosstool_top=@rules_haskell_ghc_windows_amd64//:cc_toolchain //:HelloHaskellhttps://stackoverflow.com/questions/59669961
复制相似问题