5

I'm trying to install packages which require a different version of base than the one I have installed (I have 4.6.0.0, they require < 4.6). How can I install these on my system?

Edit: These packages actually require older packages in order to build, not just as a .cabal constraint.

bfops
  • 5,348
  • 5
  • 36
  • 48

3 Answers3

4

Since you can't reinstall base, the only way to get these packages installed before they are updated is to grab the source,

cabal unpack foo

and then edit foo.cabal, changing the upper bound for base there, bump the package version (append a .1) so that when installing other packages cabal doesn't think it is broken, since the .cabal file it knows (from the package index) says it requires a different version of base, and

cabal install

from the directory you unpacked to.

Since there were a few significant changes in base-4.6; the Eq and Show superclasses have been removed from Num, and Bits no longer has Num as a superclass, it may be necessary to fix the code by adding Eq, Show or Num to the constraints of some functions to make the packages compile.

That's inconvenient, but the price for being up-to-date yourself with the newest GHC version for a few weeks.

Daniel Fischer
  • 181,706
  • 17
  • 308
  • 431
  • If I do that, I get a message telling me that it can't satisfy the constraints for base, and aborts the installation. – bfops Oct 15 '12 at 23:51
  • @RobotGymnast Which package specifically are you trying to install? – Daniel Fischer Oct 15 '12 at 23:54
  • Original post updated for clarification. Installing Crypto in particular. – bfops Oct 15 '12 at 23:56
  • @RobotGymnast [Crypto](http://hackage.haskell.org/package/Crypto) has `base >= 3 && < 5` as constraint, that ought to work without manual intervention. What problems exactly arise when you try to install that? – Daniel Fischer Oct 15 '12 at 23:59
  • Crypto makes an assumption about the Bits datatype which is no longer true in base 4.6.* (i.e. that it inherits from Num). Because of this, Crypto fails to compile. I want to specify that it depends on an older version of Data.Bits, and, by extension, base. – bfops Oct 16 '12 at 02:06
  • You can't have an older version of base without installing an older GHC. So either that, or fix the type signatures yourself. I'd go with the second route. – Daniel Fischer Oct 16 '12 at 08:55
1

If you just want one of your programs to depend on these packages, you can use cabal-dev as a drop-in replacement for cabal. The former installs local copies of packages in a cabal-dev path in the current directory. To install it, just run:

cabal install cabal-dev

For portability, you may add something like this to a makefile:

CABAL ?= cabal

build :
    $(CABAL) build --builddir=$(BUILD_PATH)

Then in your Bash settings:

CABAL=cabal-dev
export CABAL
Jon Purdy
  • 53,300
  • 8
  • 96
  • 166
1

If a package isn't compatible with the base you currently have (i.e. just changing the constraint is insufficient), your only options are to port the package yourself or use an older ghc that provides the correct version of base.

You might want to check with the package maintainer first though. A development branch may already support what you need, and they just need a little prodding to release it.

John L
  • 27,937
  • 4
  • 73
  • 88