堆栈无法正确解析依赖关系

时间:2017-01-21 06:46:22

标签: haskell dependency-management haskell-stack hakyll

我试图在新的Ubuntu 16.04实例上设置Hakyll,但我似乎无法正确获得基于堆栈的设置说明。

stack install hakyll开始,我得到:

Error: While constructing the build plan, the following exceptions were encountered:

In the dependencies for hakyll-4.9.3.0:
    http-conduit-2.1.11 must match >=2.2 && <2.3 (latest applicable is 2.2.3)

Plan construction failed.

我在与stack-install http-conduit-2.1.11搭讪时遇到了类似的错误,这次是:

Error: While constructing the build plan, the following exceptions were encountered:

In the dependencies for http-conduit-2.2.3:
    http-client-0.4.31.2 must match >=0.5 && <0.6 (latest applicable is 0.5.5)
    http-client-tls-0.2.4.1 must match >=0.3 && <0.4 (latest applicable is 0.3.3.1)

Plan construction failed.

在为此解析依赖关系(也使用Stack)后,我再次尝试stack install http-conduit-2.1.11,但我再次遇到了相同的依赖错误。

http-client-0.4.31.2http-client-tls-0.2.4.1出现在我的~/.stack/precompiled/x86_64-linux/ghc-8.0.1/1.24.0.0/中,我的$PATH中没有明确显示,但这感觉就像是一个非常hacky的解决方案,并且我还没有找到任何推荐这种方法的文档。

如何在我的机器上正确安装Hakyll?

2 个答案:

答案 0 :(得分:3)

使用堆栈的依赖关系管理意味着可重现和声明,这意味着只有在项目的.cabal文件中记录所有依赖关系并且项目的stack.yaml定义后,堆栈项目才会编译这些依赖项的版本位于resolverextra-deps部分。

你的困惑似乎源于对stack install所做的误解。命令行帮助可以这样说:

  build                    Build the package(s) in this directory/configuration
  install                  Shortcut for 'build --copy-bins'
...
  --[no-]copy-bins         Enable/disable copying binaries to the local-bin-path
                           (see 'stack path')

stack install 保存任何依赖项。

因此,将hakyll作为对代码的依赖关系的正确方法是:

  • 如果您已经拥有Cabal套餐,请使用stack init创建正确的堆栈项目,如果您没有,则创建stack new

  • hakyll添加到.cabal文件中的库或可执行文件build-depends

  • 尝试stack build并按照任何错误消息中的说明操作,直到所有问题都得到解决。

答案 1 :(得分:2)

在这种情况下,比@ sjakobi更简单的解决方案是在启动新的Stack项目时将解析器指定为命令行选项:

stack install hakyll --resolver=5.11 --install-ghc
相关问题