使用 'stack build --profile' 时的依赖性问题?

Dependency issues when using 'stack build --profile'?

重现步骤:

$ stack new profiling-test
$ cd profiling-test
$ stack build --profile

使用 lts-7.2 和默认模板初始化新项目。我收到错误:

While constructing the BuildPlan the following exceptions were encountered:

--  While attempting to add dependency,
    Could not find package base in known packages

--  Failure when adding dependencies:
      base: needed (>=4.7 && <5), stack configuration has no specified version (latest applicable is 4.9.0.0)
    needed for package profiling-test-0.1.0.0

Recommended action: try adding the following to your extra-deps in ~/profiling-test/stack.yaml
- base-4.9.0.0

You may also want to try the 'stack solver' command

如果我只做 stack build,它可以正常编译,没有任何错误。

我在 stack.yaml 中将 base-4.9.0.0 添加到 extra-deps,但我得到了同样的错误。

我的堆栈版本是:

$ stack --version
Version 1.1.3, Git revision 225df244ea346a8dc880ef911b002583486a92b2 x86_64 hpack-0.14.0

而且我 运行 Ubuntu 14.04 值得信赖。

在此先感谢您的帮助!

找到https://github.com/commercialhaskell/stack/issues/1331后想通了。

解决方案:

  • 而不是做

    $ stack build --profile
    
  • 做:

    $ stack build --profile --no-system-ghc
    

然后只需将 --no-system-ghc 添加到所有内容即可。您可能还需要在一切之前做 stack setup --no-system-ghc

或者,如评论所建议,您可以将此添加到项目或全局堆栈项目的 stack.yaml