gpt4 book ai didi

haskell - 从 Cabal 安装时覆盖 -Werror

转载 作者:行者123 更新时间:2023-12-02 10:06:41 27 4
gpt4 key购买 nike

我正在尝试安装 nano-hmac-0.2.0使用 Cabal 和 GHC 6.12.1 从 Hackage 中下载包(我想要的包的依赖项),但失败并出现以下错误:

Data/Digest/OpenSSL/HMAC.hsc:1:0:
Warning: Module `Prelude' is deprecated:
You are using the old package `base' version 3.x.
Future GHC versions will not support base version 3.x. You
should update your code to use the new base version 4.x.

<no location info>:
Failing due to -Werror.

果然,包的 .cabal 文件中有以下行:

  ghc-options:         -Wall -Werror -O2 -fvia-C

我希望能够覆盖 -Werror 选项,这样我就可以在不手动修改 .cabal 文件的情况下安装该软件包,但找不到可行的方法。特别是,我尝试将 --ghc-options 传递给 Cabal,以在 GHC 的参数列表中粘贴 -Wwarn,如下所示:

$ cabal install nano-hmac-0.2.0 -v2 --ghc-options='-Wwarn'

但这并没有达到我想要的效果;详细输出验证了 -Wwarn 已添加到 GHC 参数列表的开头,但 .cabal 文件中的 -Werror 稍后出现,并且似乎覆盖了它:

/usr/bin/ghc -Wwarn --make -package-name nano-hmac-0.2.0 -hide-all-packages -fbuilding-cabal-package -i -idist/build -i. -idist/build/autogen -Idist/build/autogen -Idist/build -optP-include -optPdist/build/autogen/cabal_macros.h -odir dist/build -hidir dist/build -stubdir dist/build -package-id base-3.0.3.2-0092f5a086872e0cdaf979254933cd43 -package-id bytestring-0.9.1.5-125aff5b9d19ec30231ae2684b8c8577 -O -Wall -Werror -O2 -fvia-C -XForeignFunctionInterface -XBangPatterns -XCPP Data.Digest.OpenSSL.HMAC

我还尝试将 --constraint='base >= 4' 传递给 Cabal 以强制它使用更新版本的 base 并完全避免警告,但我遇到了同样的失败,我仍然在详细输出中看到以下内容:

Dependency base ==3.0.3.2: using base-3.0.3.2

有没有办法通过 Cabal 命令行消除或覆盖来自 .cabal 文件的 -Werror,还是我自己只能修改 .cabal 文件?

最佳答案

Is there a way to get rid of or override the -Werror coming from the .cabal file via the Cabal command line, or am I stuck modifying the .cabal file myself?

确实如此。一般情况下是没有办法的。您也许能够覆盖包限制,以使警告消失,但是,通常您必须修改 .cabal 文件。

如今,Hackage 会阻止人们上传 .cabal 文件中带有 -Werror 的软件包,因此随着时间的推移,这个问题将会消失。

关于haskell - 从 Cabal 安装时覆盖 -Werror,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4941284/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com