October 28, 2014

I recently moved to a new laptop and decided to rethink my GHC and cabal setup. After installing GHC for Mac OS X and running cabal install cabal-install, I decided not to install any other cabal packages globally in order to avoid cabal hell. However, there are a few programs I link to install globally with cabal, e.g. pandoc. I asked Tyler Holien what he does, and he suggested a separate cabal sandbox for each program and a symlink to the resulting binary somewhere on my $PATH.

I created a script called glabal to do the first part of this work for me:

# ~/bin/glabal:
mkdir -p ~/.installs/$1
pushd ~/.installs/$1
cabal sandbox init
cabal install $1 -j8

To use this, I type glabal pandoc and it creates a sandbox in .installs/pandoc and attempts to install pandoc. If this doesn’t complete successfully, I either rm -r .install/pandoc or go into the sandbox manually and attempt to recover.