A)我正在尝试用NixOS(channels / nixos-18.03)创建一个Haskell项目i)with Stack,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来解决缺少的库。但是进一步的上游错误从那里开始(例如:我不能将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问题commercialhaskell/stack
的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
)修复了问题。