Paul Kuliniewicz
Paul Kuliniewicz

Reputation: 2731

Override -Werror when installing from Cabal

I'm trying to install the nano-hmac-0.2.0 package (a dependency of a package I want) from Hackage using Cabal and GHC 6.12.1, but it fails with the following error:

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.

Sure enough, the package's .cabal file has the following line in it:

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

I'd like to be able to override the -Werror option so I can install the package without manually modifying the .cabal file, but can't find a way that will work. In particular, I tried passing --ghc-options to Cabal to stick a -Wwarn in GHC's argument list, like this:

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

This doesn't do what I want, though; the verbose output verifies that -Wwarn is getting added to the beginning of GHC's argument list, but the -Werror from the .cabal file appears later and seems to override it:

/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

I also tried passing --constraint='base >= 4' to Cabal to force it to use a more recent version of base and avoid the warning entirely, but I get the same failure, and I still see the following in the verbose output:

Dependency base ==3.0.3.2: using base-3.0.3.2

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?

Upvotes: 9

Views: 1026

Answers (1)

Don Stewart
Don Stewart

Reputation: 137987

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?

Indeed. There's no way in general. You may be able to override package constraints such that the warnings go away, however, in general, you must modify the .cabal file.

These days Hackage prevents people uploading packages with -Werror in their .cabal file, so the issue will go away over time.

Upvotes: 6

Related Questions