EDIT FOR FUTURE SOULS STUMBLING ONTO THIS:
It would be unwise to copy any of my commands below, do not execute them. Just check out Zeta's answer for why I was approaching this incorrectly.
ORIGINAL QUESTION
My sandbox seems to be getting caught on a global version of some packages rather than using the sandbox versions. I've looked around on SO for answers to this, and many of the questions are answered without specific instructions to resolve this, or were slightly different, so I can't seem to get my setup running. Here's what I have:
1. Version of cabal is old:
$ cabal --v
cabal-install version 1.16.0.2
using version 1.16.0 of the Cabal library
Oh dear, this is old and won't run sandbox.
2. Install cabal with cabal
$ cabal install cabal
Resolving dependencies...
Downloading Cabal-1.22.6.0...
...lots of stuf...
Registering Cabal-1.22.6.0...
Installed Cabal-1.22.6.0
Looks good.
3. Try it out:
$ cabal sandbox init
cabal: unrecognised command: sandbox (try --help)
Hmm.
$ which cabal
/usr/bin/cabal
Ahh.
$ ${HOME}/.cabal/bin/cabal --version
cabal-install version 1.22.2.0
using version 1.22.2.0 of the Cabal library
Aha.
$ export PATH="${HOME}/.cabal/bin/:$PATH"
$ export PATH="${HOME}/.cabal/libs/:$PATH"
$ cabal --v
cabal-install version 1.22.2.0
Great.
4. Try it out again:
$ cabal sandbox init
Writing a default package environment file to
.../cabal.sandbox.config
Creating a new sandbox at .../.cabal-sandbox
$ cabal install Frames
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: Frames-0.1.2.1 (user goal)
next goal: base (dependency of Frames-0.1.2.1)
rejecting: base-4.6.0.1/installed-8aa... (conflict: Frames => base>=4.7 &&
<4.9)
rejecting: base-4.8.2.0, 4.8.1.0, 4.8.0.0, 4.7.0.2, 4.7.0.1, 4.7.0.0, 4.6.0.1,
4.6.0.0, 4.5.1.0, 4.5.0.0, 4.4.1.0, 4.4.0.0, 4.3.1.0, 4.3.0.0, 4.2.0.2,
4.2.0.1, 4.2.0.0, 4.1.0.0, 4.0.0.0, 3.0.3.2, 3.0.3.1 (global constraint
requires installed instance)
Dependency tree exhaustively searched.
Note: when using a sandbox, all packages are required to have consistent
dependencies. Try reinstalling/unregistering the offending packages or
recreating the sandbox.
Huh, so base is not compatible, OK.
$ cabal install base --reinstall
Resolving dependencies...
cabal: Could not resolve dependencies:
next goal: base (user goal)
rejecting: base-4.8.2.0, 4.8.1.0, 4.8.0.0, 4.7.0.2, 4.7.0.1, 4.7.0.0, 4.6.0.1,
4.6.0.0, 4.5.1.0, 4.5.0.0, 4.4.1.0, 4.4.0.0, 4.3.1.0, 4.3.0.0, 4.2.0.2,
4.2.0.1, 4.2.0.0, 4.1.0.0, 4.0.0.0 (only already installed instances can be
used)
rejecting: base-3.0.3.2 (conflict: base => base>=4.0 && <4.3)
rejecting: base-3.0.3.1 (conflict: base => base>=4.0 && <4.2)
Dependency tree exhaustively searched.
Note: when using a sandbox, all packages are required to have consistent
dependencies. Try reinstalling/unregistering the offending packages or
recreating the sandbox.
Huh, what about all dependencies?
$ cabal install --upgrade-dependencies
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: Frames-0.1.2.1 (user goal)
next goal: base (dependency of Frames-0.1.2.1)
rejecting: base-4.8.2.0, 4.8.1.0, 4.8.0.0, 4.7.0.2, 4.7.0.1, 4.7.0.0 (global
constraint requires installed instance)
rejecting: base-4.6.0.1/installed-8aa... (conflict: Frames => base>=4.7 &&
<4.9)
rejecting: base-4.6.0.1, 4.6.0.0, 4.5.1.0, 4.5.0.0, 4.4.1.0, 4.4.0.0, 4.3.1.0,
4.3.0.0, 4.2.0.2, 4.2.0.1, 4.2.0.0, 4.1.0.0, 4.0.0.0, 3.0.3.2, 3.0.3.1 (global
constraint requires installed instance)
Dependency tree exhaustively searched.
Note: when using a sandbox, all packages are required to have consistent
dependencies. Try reinstalling/unregistering the offending packages or
recreating the sandbox.
Seems I cannot reinstall/unregister the offending packages. I wish the error message would give me a little more on how to do this, because the "--reinstall" flag was my best shot.
Well, it offered 2 solutions, so let's try the other, to recreate the sandbox.
$ cabal sandbox delete
Deleting the sandbox located at .../.cabal-sandbox
$ cabal sandbox init
Writing a default package environment file to
.../cabal.sandbox.config
Creating a new sandbox at .../.cabal-sandbox
$ cabal install --upgrade-dependencies
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: Frames-0.1.2.1 (user goal)
next goal: base (dependency of Frames-0.1.2.1)
rejecting: base-4.8.2.0, 4.8.1.0, 4.8.0.0, 4.7.0.2, 4.7.0.1, 4.7.0.0 (global
constraint requires installed instance)
rejecting: base-4.6.0.1/installed-8aa... (conflict: Frames => base>=4.7 &&
<4.9)
rejecting: base-4.6.0.1, 4.6.0.0, 4.5.1.0, 4.5.0.0, 4.4.1.0, 4.4.0.0, 4.3.1.0,
4.3.0.0, 4.2.0.2, 4.2.0.1, 4.2.0.0, 4.1.0.0, 4.0.0.0, 3.0.3.2, 3.0.3.1 (global
constraint requires installed instance)
Dependency tree exhaustively searched.
Note: when using a sandbox, all packages are required to have consistent
dependencies. Try reinstalling/unregistering the offending packages or
recreating the sandbox.
This also did not help. Fresh out of ideas. How do I use sandbox? My read here is there is a global something that is causing a problem. A sandbox should not be bothered by that by design of sandboxing, right?
If it helps context, I'm just trying to run the demo for Frames:
https://github.com/acowley/Frames
...which is:
$ cabal sandbox init
$ cabal install --dependencies-only -f demos # <-- here
I see there's a closed issue on this step, but that seems like a different issue.
base
is tightly coupled to GHC's version. Since your Cabal is 1.16, I guess you're using GHC 7.6.x, which is common in older Linux LTS distributions (e.g. Ubuntu 14.04). Try theghc-x.y.z
packages by hvr (on launchpad) orstack
instead, or otherwise grab a newer version. If you don't want to switch GHC, For Frames you need at least GHC 7.8.x. – Kinetichttps://www.haskell.org/platform/#linux-ubuntu
and follow its instructions, it tells mehaskell-platform is already the newest version.
– Baptistahaskell-platform
debs (only symlinks forghc
, etc will be overwritten), and you can use the-w
flag in cabal to use different versions of GHC (and consequentlybase
) in a cabal project. But yes you should probably just usestack
as zeta suggests; it sounds like it's a much more user-friendly work-flow and can handle installing ghc. – Willingham