Search code examples
haskellyesod

Cannot install yesod with "duplicate instance declaration"


When I try to install yesod using the command "cabal install yesod", I got the following errors:

cabal install rsa
Resolving dependencies...
Configuring RSA-1.0.6.1...
Preprocessing library RSA-1.0.6.1...
Preprocessing executables for RSA-1.0.6.1...
Building RSA-1.0.6.1...
[1 of 1] Compiling Codec.Crypto.RSA ( Codec/Crypto/RSA.hs, dist/build/Codec/Crypto/RSA.o )

Codec/Crypto/RSA.hs:577:10:
    Duplicate instance declarations:
      instance Random Word8 -- Defined at Codec/Crypto/RSA.hs:577:10-21
      instance Random Word8 -- Defined in System.Random
cabal: Error: some packages failed to install:

It seems RSA lib conflicts with another library.

Any idea?

My environment: Mac OS X 10.7 GHC 7.0.3

Thanks in advance.


Solution

  • The random package started exporting new instances in version 1.0.1.0. One solution would be to conditionally compile the RSA library's instance only when the random package is that version or later; some variation like this should work:

    {-# LANGUAGE CPP #-}
    #if MIN_VERSION_random(1,0,1)
    #else
    instance Random Word8 where
        ...
    #endif
    

    Bonus points if you send a patch to the maintainer of the RSA library.

    Alternately, you could ask cabal to use an older version of random.