簡體   English   中英

堆棧無法正確解決依賴關系

[英]Stack not resolving dependencies properly

我正在嘗試在新的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 ,但是感覺像是一個非常棘手的解決方案,而且我還沒有找到任何文檔推薦這種方法。

如何在機器上正確安裝Hakyll?

堆棧的依賴關系管理具有可重復性和聲明性,這意味着只有在所有依賴關系都記錄在項目的.cabal文件中之后,並且一旦stack.yaml為這些項目定義了版本,堆棧項目才會編譯resolverextra-deps部分中extra-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項目,否則,請使用stack new

  • 向您的.cabal文件中的庫或可執行文件build-depends中添加hakyll

  • 嘗試stack build並按照任何錯誤消息中的說明進行操作,直到解決所有問題。

在這種情況下,比@sjakobi的解決方案更簡單的解決方案是在啟動新的Stack項目時將解析器指定為命令行選項:

stack install hakyll --resolver=5.11 --install-ghc

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM