"ghc-cabal: No such file or directory" 构建时出错 Haskell NixOS 中的堆栈示例
"ghc-cabal: No such file or directory" error while building Haskell Stack example in NixOS
A) 我正在尝试在 NixOS (channels/nixos-18.03) 上使用 Stack 创建一个 Haskell 项目 i),ii)。在按照用户指南中的 HelloWorld example 构建项目时,我收到错误 ghc-cabal: No such file or directory
。
$ stack new helloworld new-template
$ cd helloworld
$ sudo stack build
...
Running /run/current-system/sw/bin/make install in directory /root/.stack/programs/x86_64-linux/ghc-8.6.4.temp/ghc-8.6.4/ exited with ExitFailure 2
...
utils/ghc-cabal/dist-install/build/tmp/ghc-cabal-bindist: line 3: /root/.stack/programs/x86_64-linux/ghc-8.6.4.temp/ghc-8.6.4/utils/ghc-cabal/dist-install/build/tmp/ghc-cabal: No such file or directory
make[1]: *** [ghc.mk:990: install_packages] Error 127
make: *** [Makefile:51: install] Error 2
Error: Error encountered while installing GHC with
make install
run in /root/.stack/programs/x86_64-linux/ghc-8.6.4.temp/ghc-8.6.4/
The following directories may now contain files, but won't be used by stack:
- /root/.stack/programs/x86_64-linux/ghc-8.6.4.temp/
- /root/.stack/programs/x86_64-linux/ghc-8.6.4/
B) 迭代地,我建立了我的 /etc/nixos/configuration.nix
文件,看起来像这样。在生成的系统中,确实没有 ghc-cabal
二进制文件。有 cabal
,但没有 ghc-cabal
。
environment.systemPackages = with pkgs; [
wget vim emacs
pkgs.firefoxWrapper pkgs.chromium
stack
haskellPackages.ghc
haskellPackages.cabal-install
haskellPackages.cabal2nix
haskellPackages.hdevtools
tree gnumake which binutils gcc clang coreutils gnutar
tmux silver-searcher gitAndTools.gitFull
];
C) 我也遵循了 Stack 的 Nix Integration 部分中的步骤。但无济于事。
安装什么包ghc-cabal
? stack
和 haskellPackages.cabal-install
之间是否存在不匹配?我错过了什么?
编辑
我做了一些挖掘,发现了一些有用的资源。
特别是,this article 指出我的问题可能是由未解析的动态库引起的。
确实在查询该二进制文件的加载库时,我得到了以下结果。
$ ldd ~/.stack/programs/x86_64-linux/ghc-8.6.4.temp/ghc-8.6.4/utils/ghc-cabal/dist-install/build/tmp/ghc-cabal
linux-vdso.so.1 (0x00007fff0ab01000)
libm.so.6 => /nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libm.so.6 (0x00007fe82c07f000)
libHSCabal-2.4.0.1-ghc8.6.4.so => not found
libHSprocess-1.6.5.0-ghc8.6.4.so => not found
libHSpretty-1.1.3.6-ghc8.6.4.so => not found
libHSparsec-3.1.13.0-ghc8.6.4.so => not found
libHStext-1.2.3.1-ghc8.6.4.so => not found
libHSmtl-2.2.2-ghc8.6.4.so => not found
libHStransformers-0.5.6.2-ghc8.6.4.so => not found
libHSdirectory-1.3.3.0-ghc8.6.4.so => not found
libHSunix-2.7.2.2-ghc8.6.4.so => not found
libHStime-1.8.0.2-ghc8.6.4.so => not found
libHSfilepath-1.4.2.1-ghc8.6.4.so => not found
libHSbinary-0.8.6.0-ghc8.6.4.so => not found
libHScontainers-0.6.0.1-ghc8.6.4.so => not found
libHSbytestring-0.10.8.2-ghc8.6.4.so => not found
libHSdeepseq-1.4.4.0-ghc8.6.4.so => not found
libHSarray-0.5.3.0-ghc8.6.4.so => not found
libHSbase-4.12.0.0-ghc8.6.4.so => not found
libHSinteger-gmp-1.0.2.0-ghc8.6.4.so => not found
libHSghc-prim-0.5.3-ghc8.6.4.so => not found
libHSrts-ghc8.6.4.so => not found
libffi.so.7 => not found
librt.so.1 => /nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/librt.so.1 (0x00007fe82c06d000)
libutil.so.1 => /nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libutil.so.1 (0x00007fe82c068000)
libdl.so.2 => /nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libdl.so.2 (0x00007fe82c063000)
libpthread.so.0 => /nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libpthread.so.0 (0x00007fe82c042000)
libgmp.so.10 => not found
libc.so.6 => /nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libc.so.6 (0x00007fe82be8a000)
/lib64/ld-linux-x86-64.so.2 => /nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib64/ld-linux-x86-64.so.2 (0x00007fe82c219000)
我尝试通过将 haskellPackages.stdio
和 haskellPackages.stdf
添加到 configuration.nix 来解决缺少的库。但是进一步的上游错误 spring (例如:我不能将 aeson 添加为 environment.systemPackages
依赖项)。所以我还没有得到正确的组合。
CallStack (from HasCallStack):
die', called at libraries/Cabal/Cabal/Distribution/Simple/Configure.hs:950:20 in Cabal-2.4.0.1:Distribution.Simple.Configure
configureFinalizedPackage, called at libraries/Cabal/Cabal/Distribution/Simple/Configure.hs:460:12 in Cabal-2.4.0.1:Distribution.Simple.Configure
configure, called at libraries/Cabal/Cabal/Distribution/Simple.hs:596:20 in Cabal-2.4.0.1:Distribution.Simple
confHook, called at libraries/Cabal/Cabal/Distribution/Simple/UserHooks.hs:67:5 in Cabal-2.4.0.1:Distribution.Simple.UserHooks
configureAction, called at libraries/Cabal/Cabal/Distribution/Simple.hs:178:19 in Cabal-2.4.0.1:Distribution.Simple
defaultMainHelper, called at libraries/Cabal/Cabal/Distribution/Simple.hs:115:27 in Cabal-2.4.0.1:Distribution.Simple
defaultMain, called at Setup.hs:2:8 in main:Main
Setup: Encountered missing dependencies:
aeson ==0.8.*, base ==4.7.*, binary ==0.7.*, text ==1.1.*
ghc-cabal 是 ghc 构建中的一个工件,包含在 ghc 二进制发行版中:
$ ls -l ~/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.3.tar.xz
-rw-rw-r--. 1 user group 182356948 Dec 25 15:11 ghc-tinfo6-8.6.3.tar.xz
$ tar tvf ~/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.3.tar.xz | grep tmp/ghc-cabal
-rwxr-xr-x ghc/ghc 225936 2018-12-08 00:03 ghc-8.6.3/utils/ghc-cabal/dist-install/build/tmp/ghc-cabal
-rwxr-xr-x ghc/ghc 858 2018-12-08 00:03 ghc-8.6.3/utils/ghc-cabal/dist-install/build/tmp/ghc-cabal-bindist
所以我在 Kirill Zaborsky in a commercialhaskell/stack
issues thread 的帮助下解决了这个问题。错误的原因(在 stack new
和 stack build
中)是旧的 Stack 版本。具体来说,我的本地用户的堆栈 (1.6.5
) 比 root (1.9.3
) 旧。
版本 1.6.5 使用 Cabal-2.0
,从那时起,Cabal
(例如 base-noprelude
)引入了新功能,使用前导逗号,在 haskell/cabal#4953 中实现与 2.2。因此 Stack 无法使用新格式功能解析 cabal 文件。
详细信息在 commercialhaskell/stack
期 thread 中。升级我本地用户的堆栈 (nix-env --upgrade stack
) 解决了这个问题。
A) 我正在尝试在 NixOS (channels/nixos-18.03) 上使用 Stack 创建一个 Haskell 项目 i),ii)。在按照用户指南中的 HelloWorld example 构建项目时,我收到错误 ghc-cabal: No such file or directory
。
$ stack new helloworld new-template
$ cd helloworld
$ sudo stack build
...
Running /run/current-system/sw/bin/make install in directory /root/.stack/programs/x86_64-linux/ghc-8.6.4.temp/ghc-8.6.4/ exited with ExitFailure 2
...
utils/ghc-cabal/dist-install/build/tmp/ghc-cabal-bindist: line 3: /root/.stack/programs/x86_64-linux/ghc-8.6.4.temp/ghc-8.6.4/utils/ghc-cabal/dist-install/build/tmp/ghc-cabal: No such file or directory
make[1]: *** [ghc.mk:990: install_packages] Error 127
make: *** [Makefile:51: install] Error 2
Error: Error encountered while installing GHC with
make install
run in /root/.stack/programs/x86_64-linux/ghc-8.6.4.temp/ghc-8.6.4/
The following directories may now contain files, but won't be used by stack:
- /root/.stack/programs/x86_64-linux/ghc-8.6.4.temp/
- /root/.stack/programs/x86_64-linux/ghc-8.6.4/
B) 迭代地,我建立了我的 /etc/nixos/configuration.nix
文件,看起来像这样。在生成的系统中,确实没有 ghc-cabal
二进制文件。有 cabal
,但没有 ghc-cabal
。
environment.systemPackages = with pkgs; [
wget vim emacs
pkgs.firefoxWrapper pkgs.chromium
stack
haskellPackages.ghc
haskellPackages.cabal-install
haskellPackages.cabal2nix
haskellPackages.hdevtools
tree gnumake which binutils gcc clang coreutils gnutar
tmux silver-searcher gitAndTools.gitFull
];
C) 我也遵循了 Stack 的 Nix Integration 部分中的步骤。但无济于事。
安装什么包ghc-cabal
? stack
和 haskellPackages.cabal-install
之间是否存在不匹配?我错过了什么?
编辑
我做了一些挖掘,发现了一些有用的资源。 特别是,this article 指出我的问题可能是由未解析的动态库引起的。
确实在查询该二进制文件的加载库时,我得到了以下结果。
$ ldd ~/.stack/programs/x86_64-linux/ghc-8.6.4.temp/ghc-8.6.4/utils/ghc-cabal/dist-install/build/tmp/ghc-cabal
linux-vdso.so.1 (0x00007fff0ab01000)
libm.so.6 => /nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libm.so.6 (0x00007fe82c07f000)
libHSCabal-2.4.0.1-ghc8.6.4.so => not found
libHSprocess-1.6.5.0-ghc8.6.4.so => not found
libHSpretty-1.1.3.6-ghc8.6.4.so => not found
libHSparsec-3.1.13.0-ghc8.6.4.so => not found
libHStext-1.2.3.1-ghc8.6.4.so => not found
libHSmtl-2.2.2-ghc8.6.4.so => not found
libHStransformers-0.5.6.2-ghc8.6.4.so => not found
libHSdirectory-1.3.3.0-ghc8.6.4.so => not found
libHSunix-2.7.2.2-ghc8.6.4.so => not found
libHStime-1.8.0.2-ghc8.6.4.so => not found
libHSfilepath-1.4.2.1-ghc8.6.4.so => not found
libHSbinary-0.8.6.0-ghc8.6.4.so => not found
libHScontainers-0.6.0.1-ghc8.6.4.so => not found
libHSbytestring-0.10.8.2-ghc8.6.4.so => not found
libHSdeepseq-1.4.4.0-ghc8.6.4.so => not found
libHSarray-0.5.3.0-ghc8.6.4.so => not found
libHSbase-4.12.0.0-ghc8.6.4.so => not found
libHSinteger-gmp-1.0.2.0-ghc8.6.4.so => not found
libHSghc-prim-0.5.3-ghc8.6.4.so => not found
libHSrts-ghc8.6.4.so => not found
libffi.so.7 => not found
librt.so.1 => /nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/librt.so.1 (0x00007fe82c06d000)
libutil.so.1 => /nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libutil.so.1 (0x00007fe82c068000)
libdl.so.2 => /nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libdl.so.2 (0x00007fe82c063000)
libpthread.so.0 => /nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libpthread.so.0 (0x00007fe82c042000)
libgmp.so.10 => not found
libc.so.6 => /nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libc.so.6 (0x00007fe82be8a000)
/lib64/ld-linux-x86-64.so.2 => /nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib64/ld-linux-x86-64.so.2 (0x00007fe82c219000)
我尝试通过将 haskellPackages.stdio
和 haskellPackages.stdf
添加到 configuration.nix 来解决缺少的库。但是进一步的上游错误 spring (例如:我不能将 aeson 添加为 environment.systemPackages
依赖项)。所以我还没有得到正确的组合。
CallStack (from HasCallStack):
die', called at libraries/Cabal/Cabal/Distribution/Simple/Configure.hs:950:20 in Cabal-2.4.0.1:Distribution.Simple.Configure
configureFinalizedPackage, called at libraries/Cabal/Cabal/Distribution/Simple/Configure.hs:460:12 in Cabal-2.4.0.1:Distribution.Simple.Configure
configure, called at libraries/Cabal/Cabal/Distribution/Simple.hs:596:20 in Cabal-2.4.0.1:Distribution.Simple
confHook, called at libraries/Cabal/Cabal/Distribution/Simple/UserHooks.hs:67:5 in Cabal-2.4.0.1:Distribution.Simple.UserHooks
configureAction, called at libraries/Cabal/Cabal/Distribution/Simple.hs:178:19 in Cabal-2.4.0.1:Distribution.Simple
defaultMainHelper, called at libraries/Cabal/Cabal/Distribution/Simple.hs:115:27 in Cabal-2.4.0.1:Distribution.Simple
defaultMain, called at Setup.hs:2:8 in main:Main
Setup: Encountered missing dependencies:
aeson ==0.8.*, base ==4.7.*, binary ==0.7.*, text ==1.1.*
ghc-cabal 是 ghc 构建中的一个工件,包含在 ghc 二进制发行版中:
$ ls -l ~/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.3.tar.xz
-rw-rw-r--. 1 user group 182356948 Dec 25 15:11 ghc-tinfo6-8.6.3.tar.xz
$ tar tvf ~/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.3.tar.xz | grep tmp/ghc-cabal
-rwxr-xr-x ghc/ghc 225936 2018-12-08 00:03 ghc-8.6.3/utils/ghc-cabal/dist-install/build/tmp/ghc-cabal
-rwxr-xr-x ghc/ghc 858 2018-12-08 00:03 ghc-8.6.3/utils/ghc-cabal/dist-install/build/tmp/ghc-cabal-bindist
所以我在 Kirill Zaborsky in a commercialhaskell/stack
issues thread 的帮助下解决了这个问题。错误的原因(在 stack new
和 stack build
中)是旧的 Stack 版本。具体来说,我的本地用户的堆栈 (1.6.5
) 比 root (1.9.3
) 旧。
版本 1.6.5 使用 Cabal-2.0
,从那时起,Cabal
(例如 base-noprelude
)引入了新功能,使用前导逗号,在 haskell/cabal#4953 中实现与 2.2。因此 Stack 无法使用新格式功能解析 cabal 文件。
详细信息在 commercialhaskell/stack
期 thread 中。升级我本地用户的堆栈 (nix-env --upgrade stack
) 解决了这个问题。