ubuntuhaskellwindows-subsystem-for-linuxcabalhaskell-platform

WSL: Cabal could not resolve dependencies. containers, binary


I am quite new at using haskell and cabal, and I'm trying to install the package haskell package plot with cabal install --lib plot and I get this

Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: binary-0.8.8.0/installed-0.8.8.0 (user goal)
[__1] next goal: containers (user goal)
[__1] rejecting: containers-0.6.4.1 (conflict: binary =>
containers==0.6.2.1/installed-0.6.2.1)
[__1] rejecting: containers-0.6.3.1, containers-0.6.2.1/installed-0.6.2.1,
containers-0.6.2.1, containers-0.6.1.1, containers-0.6.0.1,
containers-0.5.11.0, containers-0.5.10.2, containers-0.5.10.1,
containers-0.5.9.2, containers-0.5.8.2, containers-0.5.7.1,
containers-0.5.7.0, containers-0.5.6.3, containers-0.5.6.2,
containers-0.5.6.1, containers-0.5.6.0, containers-0.5.5.1,
containers-0.5.5.0, containers-0.5.4.0, containers-0.5.3.1,
containers-0.5.3.0, containers-0.5.2.1, containers-0.5.2.0,
containers-0.5.1.0, containers-0.5.0.0, containers-0.4.2.1,
containers-0.4.2.0, containers-0.4.1.0, containers-0.4.0.0,
containers-0.3.0.0, containers-0.2.0.1, containers-0.2.0.0,
containers-0.1.0.1, containers-0.1.0.0, containers-0.5.9.1, containers-0.5.8.1
(constraint from user target requires ==0.6.4.1)
[__1] fail (backjumping, conflict set: binary, containers)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: binary, containers, ghc

I tried installing containers and binary seperately but I get similar errors.


Solution

  • This is what happens when you use cabal install --lib without understanding exactly what it does. In short, it's not suitable for having a global library set that you keep updating. It's really only usable once. To use it again, you'd have to delete the environment file it creates and use it with the full list of libraries you want available in a single cabal invocation. This is honestly a pain, and in almost all cases using a cabal file is a better way to work.

    Create a new directory, run cabal init inside it, add your required packages to the generated cabal file, put your code in the generated Main.hs, experiment with cabal repl, run with cabal exec. It doesn't have to be any more complicated than that, and you avoid causing yourself extra problems by pinning package versions independently of each other.