How to downgrade base with cabal?

主宰稳场 提交于 2019-12-23 10:08:42

问题


I'm trying to install a program called clanki on Windows 10. In it's installation doc it says to use 'cabal install clanki'. I downloaded cabal, then ghc. Now I run into a version problem for the package base.

$ cabal install clanki
Resolving dependencies...
cabal.exe: Could not resolve dependencies:
trying: clanki-1.2.7 (user goal)
next goal: base (dependency of clanki-1.2.7)
rejecting: base-4.9.0.0/installed-4.9... (conflict: clanki => base<=4.9.0)
rejecting: base-4.9.0.0, base-4.8.2.0, base-4.8.1.0, base-4.8.0.0,
base-4.7.0.2, base-4.7.0.1, base-4.7.0.0, base-4.6.0.1, base-4.6.0.0,
base-4.5.1.0, base-4.5.0.0, base-4.4.1.0, base-4.4.0.0, base-4.3.1.0,
base-4.3.0.0, base-4.2.0.2, base-4.2.0.1, base-4.2.0.0, base-4.1.0.0,
base-4.0.0.0, base-3.0.3.2, base-3.0.3.1 (constraint from non-upgradeable
package requires installed instance)
Dependency tree exhaustively searched.

So clanki requires base to be older than 4.9 (stack says this more clearly than cabal), and I then would like to downgrade base to 4.8.2.0. When I try ghc-pkg unregister base, it doesn't allow me. Not even with --force:

$ ghc-pkg unregister base --force
unregistering would break the following packages: xhtml-3000.2.1 Win32-2.3.1.1 transformers-0.5.2.0 time-1.6.0.1 template-haskell-2.11.0.0 process-1.4.2.0 pretty-1.1.3.3 hpc-0.6.0.3 hoopl-3.10.2.1 haskeline-0.7.2.3 ghci-8.0.1 ghc-boot-th-8.0.1 ghc-boot-8.0.1 ghc-8.0.1 filepath-1.4.1.0 directory-1.2.6.2 deepseq-1.4.2.0 containers-0.5.7.1 Cabal-1.24.0.0 bytestring-0.10.8.1 binary-0.8.3.0 array-0.5.1.1 (ignoring)

As I mentioned, I tried also with stack, but in the end it also comes down to the wrong version of base. How can I downgrade this package?


回答1:


You can't. base is fixed to the GHC install; the only way to get a different version is to install an older compiler, i.e. GHC-7.10. stack would automatically do that for you, but I wouldn't be sure if that's the best solution.

Likely enough, the package will actually work with GHC-8.0; in fact the constraint base <= 4.9.0 indicates that it should. That constraint doesn't make a lot of sense since it only allows the pre-first subrevision; it should probably really be base < 4.10.

So the best thing would be to download the source from github, where base does in fact not have the upper bound, and install it from the local folder with cabal install. If that works, notify the author to relax the bound on Hackage.

If it doesn't compile in GHC-8.0, again the best thing would be to make it work by editing the source and then file a pull request.

Alternatively, I'd then resort to stack for installing the package with an older GHC. To do this, get the source code with the base < 4.9 constraint (you need to insert that in the github code), and run stack setup, stack init and stack install.




回答2:


According to @leftroundabout’s answer, the upper bound on base in this package is bogus. In such a case, or simply if you feel bold, you can instruct cabal to ignore upper bounds on dependencies with the appropriate option:

cabal install clanki --allow-newer=base


来源:https://stackoverflow.com/questions/40022261/how-to-downgrade-base-with-cabal

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