In Python there's a pip install -U -r requirements.txt
mantra to get all packages in version listed in file requirements.txt
installed, typically in virtualenv.
Is there something similar in Cabal / Haskell? After all, cabal seems to have cabal list --installed
which makes it theoretically possible to do a similar thing for a cabal sandbox.
To install all dependencies specified in your-package.cabal
, you can run
cabal install --only-dependencies
If you have created a sandbox, dependencies will be installed there.
Tip: I usually run cabal install --only-dependencies --enable-tests
to install test dependencies as well.
The cabal list --installed
lists the packages in sandbox.
If there is a sandbox in the current directory and config:ignore-sandbox is False, use the sandbox package database. Otherwise, use the package database specified with --package-db. If not specified, use the user package database.
E.g.
~/range-set-list % cabal list --installed|grep -c lens
0
~ % cabal list --installed|grep -c lens
2
~ % cabal list --installed|grep lens
* lens
Homepage: http://github.com/ekmett/lens/
Or you can take a lower level approach:
~/range-set-list % ll .cabal-sandbox/lib/x86_64-osx-ghc-7.8.3
total 0
drwxr-xr-x@ 6 ogre staff 204 Dec 23 16:50 ansi-terminal-0.6.2.1
drwxr-xr-x@ 6 ogre staff 204 Dec 23 16:50 ansi-wl-pprint-0.6.7.1
drwxr-xr-x@ 6 ogre staff 204 Dec 23 16:50 mtl-2.2.1
drwxr-xr-x@ 6 ogre staff 204 Dec 23 16:51 optparse-applicative-0.11.0.1
drwxr-xr-x@ 6 ogre staff 204 Dec 23 16:51 parsec-3.1.7
...
Looks like that not everything is installed in sandbox. Something is taken from global database still?