What to do if libraries require a different version of `base`?

二次信任 提交于 2019-12-10 14:11:58

问题


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.


回答1:


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.




回答2:


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



回答3:


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.



来源:https://stackoverflow.com/questions/12904909/what-to-do-if-libraries-require-a-different-version-of-base

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!