【发布时间】:2011-02-09 04:22:33
【问题描述】:
我正在尝试使用 Cabal 和 GHC 6.12.1 从 Hackage 安装 nano-hmac-0.2.0 包(我想要的包的依赖项),但它失败并出现以下错误:
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 文件?
【问题讨论】:
-
如果你使用
--preference='base >= 4' instead of a constraint? Also you should check that bytestring is compiled against base-4 (ghc-pkg describe bytestring`应该会显示这个)。 -
@John
--preference='base >= 4'成功了。如果您发表评论作为答案,我会接受。