haskell-stack - 堆栈构建错误 : attribute ‘ghc822’ missing,(字符串):1:53

标签 haskell-stack nixos

我正在尝试在 NixOS 上构建我的 Haskell 项目。

运行 $ stack build给出以下错误。

$ stack build
error: attribute ‘ghc822’ missing, at (string):1:53
(use ‘--show-trace’ to show detailed location information)

这个错误是什么意思,我该如何继续?当我跑 $ stack build --show-trace按照建议,我得到以下输出,我也不明白。
$ stack build --show-trace
Invalid option `--show-trace'

Usage: stack build [TARGET] [--dry-run] [--pedantic] [--fast]
                   [--ghc-options OPTIONS] [--flag PACKAGE:[-]FLAG]
                   ([--dependencies-only] | [--only-snapshot] |
                   [--only-dependencies]) ([--file-watch] | [--file-watch-poll])
                   [--exec CMD [ARGS]] [--only-configure] [--trace] [--profile]
                   [--no-strip] [--[no-]library-profiling]
                   [--[no-]executable-profiling] [--[no-]library-stripping]
                   [--[no-]executable-stripping] [--[no-]haddock]
                   [--haddock-arguments HADDOCK_ARGS] [--[no-]open]
                   [--[no-]haddock-deps] [--[no-]haddock-internal]
                   [--[no-]haddock-hyperlink-source] [--[no-]copy-bins]
                   [--[no-]copy-compiler-tool] [--[no-]prefetch]
                   [--[no-]keep-going] [--[no-]force-dirty] [--[no-]test]
                   [--[no-]rerun-tests] [--ta|--test-arguments TEST_ARGS]
                   [--coverage] [--no-run-tests] [--[no-]bench]
                   [--ba|--benchmark-arguments BENCH_ARGS] [--no-run-benchmarks]
                   [--[no-]reconfigure] [--[no-]cabal-verbose]
                   [--[no-]split-objs] [--skip ARG] [--help]
  Build the package(s) in this directory/configuration

我尝试将 channel 更改为 nixos-17.09而不是 nixos-unstable (并运行 nix-channel --update ),但仍然出现相同的错误。
$ nix-channel --list 的输出如下所示。
$ nix-channel --list
stack https://nixos.org/channels/nixos-17.09
nixos https://nixos.org/channels/nixos-17.09
$ nix-env -qaPA 'nixos.haskell.compiler'的输出显示要找到的 ghc822。
$ nix-env -qaPA 'nixos.haskell.compiler'
warning: name collision in input Nix expressions, skipping ‘/home/matthew/.nix-defexpr/channels_root/nixos’
nixos.haskell.compiler.ghc6102Binary           ghc-6.10.2-binary
nixos.haskell.compiler.ghc704                  ghc-7.0.4
nixos.haskell.compiler.ghc704Binary            ghc-7.0.4-binary
nixos.haskell.compiler.ghc7102                 ghc-7.10.2
nixos.haskell.compiler.integer-simple.ghc7102  ghc-7.10.2
nixos.haskell.compiler.ghc7103                 ghc-7.10.3
nixos.haskell.compiler.integer-simple.ghc7103  ghc-7.10.3
nixos.haskell.compiler.integer-simple.ghc742   ghc-7.4.2
nixos.haskell.compiler.ghc742                  ghc-7.4.2
nixos.haskell.compiler.ghc742Binary            ghc-7.4.2-binary
nixos.haskell.compiler.ghc763                  ghc-7.6.3
nixos.haskell.compiler.ghc783                  ghc-7.8.3
nixos.haskell.compiler.integer-simple.ghc783   ghc-7.8.3
nixos.haskell.compiler.ghc784                  ghc-7.8.4
nixos.haskell.compiler.integer-simple.ghc784   ghc-7.8.4
nixos.haskell.compiler.ghc801                  ghc-8.0.1
nixos.haskell.compiler.integer-simple.ghc801   ghc-8.0.1
nixos.haskell.compiler.ghc802                  ghc-8.0.2
nixos.haskell.compiler.integer-simple.ghc802   ghc-8.0.2
nixos.haskell.compiler.integer-simple.ghc821   ghc-8.2.1
nixos.haskell.compiler.ghc821                  ghc-8.2.1
nixos.haskell.compiler.integer-simple.ghc822   ghc-8.2.2
nixos.haskell.compiler.ghc822                  ghc-8.2.2
nixos.haskell.compiler.integer-simple.ghcHEAD  ghc-8.3.20170808
nixos.haskell.compiler.ghcHEAD                 ghc-8.3.20170808
nixos.haskell.compiler.ghcjs                   ghcjs-0.2.0
nixos.haskell.compiler.ghcjsHEAD               ghcjs-0.2.020170323
nixos.haskell.compiler.jhc                     jhc-0.8.2
nixos.haskell.compiler.uhc                     uhc-1.1.9.4

我安装了 ghc8.2.2通过 $ nix-env -iA nixos.haskell.compiler.ghc822 , 和 $ ghc --version现在回来了
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.2.2

但是,我仍然收到错误 error: attribute ‘ghc822’ missing, at (string):1:54尝试运行时 $ stack build .

另外,我试图看看 ghc我的版本 stack在此安装后使用,这导致了相同的 attribute ‘ghc822’ missing错误。
$ stack ghc -- --version
error: attribute ‘ghc822’ missing, at (string):1:54
(use ‘--show-trace’ to show detailed location information)

最佳答案

似乎您的堆栈想要检索 haskell.packages.ghc822属性或可能 haskell.compiler.ghc822 ,这在您的 <nixpkgs> 版本中不存在.

请使用 sudo nix-channel --list 检查您的 channel 配置(NixOS) 或 nix-channel --list . 17.03 及更早版本没有此属性。 17.09 和不稳定应该没问题。切换默认设置 <nixpkgs>到 17.09,记下 channel 的名称并运行

nix-channel --add https://nixos.org/channels/nixos-17.09 <NAME>

同时运行 nix-channel --update以确保您拥有最新版本。 GHC 8.2.2 于 10 月 31 日添加。

如果您不想更改 channel 配置,我想您可以设置 NIX_PATH环境变量
NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz stack build

关于haskell-stack - 堆栈构建错误 : attribute ‘ghc822’ missing,(字符串):1:53,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47916591/

相关文章:

haskell - `stack clean` 和删除 `.stack-work` 目录有什么区别?

c - 显示缺少库 : ff while building echidna using stack install

nixos - 为什么 `nix-env -q` 找不到我安装的软件包? (NixOS channel 、配置文件和软件包)

nix - 如何独立于主机的 Nixos 配置构建或测试较小的 nixos 容器配置?

nix - 如何导入 nixos 配置并将其与 nixops 部署表达式合并

haskell - 如何获取 Cabal/Stack 发出的 GHC 命令?

haskell - 堆栈: 'hdevtools is a library dependency, but the package provides no library needed since my-app is a build target.'

haskell - 为什么 Stack 选择 ghc 7.10,即使有 ghc8 的 lts?

web-scraping - 在 Nixos 上使用 systemd 计时器运行脚本

python - Nixos:如何获得带有包中包含的调试信息的 python?