2
votes

I'm following this tutorial trying to set up a Haskell project: http://shuklan.com/haskell/lec10.html#/0/9

I've had this issue before with 'cabal install'.

I get the message below. I read to try 'rm -rf ~/.ghc ~/.cabal'. I tried that and 'cabal install' again, along with 'cabal new-build' but I still get the same message.

How can I fix this? I'm on Mac OS X 10.11.4. I can make and run .hs files and us ghci. I've never created a "file structure" or anything like that with other programming languages, so I'm not familiar with what's involved.

Thank you!!


Please switch to using either the new project style and the new-install
command or the legacy v1-install alias as new-style projects will become the
default in the next version of cabal-install. Please file a bug if you cannot
replicate a working v1- use case with the new-style commands.

For more information, see: https://wiki.haskell.org/Cabal/NewBuild

Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: FirstCabalInit-0.1.0.0 (user goal)
[__1] next goal: base (dependency of FirstCabalInit)
[__1] rejecting: base-4.12.0.0/installed-4.1... (conflict: FirstCabalInit =>
base==4.6.*)
[__1] rejecting: base-4.12.0.0, base-4.11.1.0, base-4.11.0.0, base-4.10.1.0,
base-4.10.0.0, base-4.9.1.0, 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)
[__1] fail (backjumping, conflict set: FirstCabalInit, base)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base, FirstCabalInit ```
2

2 Answers

2
votes

You can find the following guide to build tools in Haskell useful:

According the error message, it looks like in your .cabal file you have a line like

build-depends: base == 4.6.*

This version of the standard library base is very old, it corresponds to GHC-7.6, however, according to the error message, you have GHC-8.6.5 installed. Since base versions are bundled with GHC, you can't use base for GHC you didn't install. See the following list of matching base and GHC versions:

It looks like your error can be resolved by the following fix:

build-depends: base == 4.12.*

For the future, I can recommend using ghcup tool to manage GHC and cabal-install versions on macOS:

Alternatively, you can use stack build tool, it manages GHC versions for you in a sandboxed location.

-2
votes

Famous "cabal hell".

You're better use newest package manager https://docs.haskellstack.org/en/stable/README/ .