Cabal fails to reinstall base or any other dependencies in sandbox Cabal

EDIT FURTHER SHOWERS THAT ARE ON THIS:

It would be unwise to copy any of my commands below, not to execute them. Just check Zeta's answer, why I was approaching this wrong.

ORIGINAL QUESTION

My sandbox seems to fall into the global version of some packages, rather than using versions for the sandbox. I looked at SO for answers to this, and many of the questions are answered without specific instructions on how to fix this, or were slightly different, so I cannot get my installation to work. Here is 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 will not run the 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)

Hm.

$ 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 

Yeah.

$ 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.

Yes, the 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.

What about all the 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.

, / . , , , "--reinstall" .

, 2 , , .

$ 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.

. . ? , , . , , ?

, Frames:

https://github.com/acowley/Frames

... :

$ cabal sandbox init
$ cabal install --dependencies-only -f demos # <-- here

, .

+4
1

(: )

base GHC. , base-4.6.0.1 GHC 7.6.3. GHC. base-4.7.0.x, GHC 7.8.x.

, base. ( ) , .

, , - . base. :

?

, /.

, , .

, Cabal . Frames 4.7, , GHC, GHC 7.8. base-4.7.x.y, GHC.

Cabal GHC.

. , Frames GHC 7.6. :

$ cabal unpack Frames
$ cd Frames-*
$ vim Frames.cabal # change the min base to something lower
$ cabal sandbox init
$ cabal build

, base Frames , .

. :

MinGHC Stack, GHC .

MinGHC ( Linux)

. Ubuntu apt Cabal GHC. , GHC Cabal /opt/, :

sudo apt-get update
sudo apt-get install -y software-properties-common
sudo add-apt-repository -y ppa:hvr/ghc
sudo apt-get update
sudo apt-get install -y cabal-install-1.22 ghc-7.10.3
cat >> ~/.bashrc <<EOF
export PATH="\$HOME/.cabal/bin:/opt/cabal/1.20/bin:/opt/ghc/7.10.3/bin:\$PATH"
EOF
export PATH=~/.cabal/bin:/opt/cabal/1.22/bin:/opt/ghc/7.10.3/bin:$PATH

cabal GHC

sudo apt-get install -y cabal-install-1.xx ghc-7.yy.z

PATH. cabal sandbox *.

Cabal. .

. : , :

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 575159689BEFB442
echo 'deb http://download.fpcomplete.com/ubuntu trusty main' | sudo tee /etc/apt/sources.list.d/fpco.list
sudo apt-get update && sudo apt-get install stack -y

stack init Cabal stack new , stack setup, GHC:

$ stack new my-project
$ cd my-project
$ stack setup
# Loooooooooooooooooooooooong log, installs GHC in background

, stack "" . LTS, . Cabal, stack build stack ghc.

, -

stack ghc --package Frames -- -O2 --make -rtsopts File1.hs File2.hs

. , , .

+9

Source: https://habr.com/ru/post/1625752/


All Articles