-
Notifications
You must be signed in to change notification settings - Fork 1
Cabal Sandbox Cheat
Using sandboxes is simple: if you already know how to use the cabal tool to build your packages, you only need to learn a few additional commands. To initialise a fresh sandbox in the current directory, run cabal sandbox init. All subsequent commands (such as build and install) from this point will use the sandbox.
$ cd /path/to/my/haskell/library
$ cabal sandbox init # Initialise the sandbox
$ cabal install --only-dependencies # Install dependencies into the sandbox
$ cabal build # Build your package inside the sandbox
It can be useful to make a source package available for installation in the sandbox - for example, if your package depends on a patched or an unreleased version of a library. This can be done with the cabal sandbox add-source command - think of it as “local Hackage”. If an add-source dependency is later modified, it is reinstalled automatically.
$ cabal sandbox add-source /my/patched/library # Add a new add-source dependency
$ cabal install --dependencies-only # Install it into the sandbox
$ cabal build # Build the local package
$ $EDITOR /my/patched/library/Source.hs # Modify the add-source dependency
$ cabal build # Modified dependency is automatically reinstalled
Sometimes one wants to share a single sandbox between multiple packages. This can be easily done with the --sandbox option:
$ cd /path/to/shared-sandbox
$ cabal sandbox init --sandbox .
$ cd /path/to/package-a
$ cabal sandbox init --sandbox /path/to/shared-sandbox
$ cd /path/to/package-b
$ cabal sandbox init --sandbox /path/to/shared-sandbox
To unregister a package, use cabal sandbox hc-pkg
$ cabal sandbox hc-pkg unregister story-board