[Haskell-cafe] multi-ghc: Managing Multiple GHC Distributions

Sean Leather leather at cs.uu.nl
Thu Apr 8 08:22:24 EDT 2010


On Thu, Apr 8, 2010 at 13:49, Bas van Dijk <v.dijk.bas at gmail.com> wrote:

> On Thu, Apr 8, 2010 at 11:00 AM, Sean Leather <leather at cs.uu.nl> wrote:
> > I created a few tools to help me manage multiple GHC distributions in a
> Bash
> > shell environment. Perhaps it's useful to others.
> >
> >   http://github.com/spl/multi-ghc
> >
> > Feedback welcome. I'd also like to know if something similar exists.
>
> Does this also work with a system installed ghc? These are usually
> installed in /usr (I'm using Gentoo Linux):
>
> $ ls -l /usr/bin/ghc*
> lrwxrwxrwx 1 root root  10 dec 22 00:22 /usr/bin/ghc -> ghc-6.12.1
> -rwxr-xr-x 1 root root 279 dec 22 00:20 /usr/bin/ghc-6.12.1
> lrwxrwxrwx 1 root root  11 dec 22 00:22 /usr/bin/ghci -> ghci-6.12.1
> -rwxr-xr-x 1 root root  61 dec 22 00:20 /usr/bin/ghci-6.12.1
> lrwxrwxrwx 1 root root  14 dec 22 00:22 /usr/bin/ghc-pkg -> ghc-pkg-6.12.1
> -rwxr-xr-x 1 root root 262 dec 22 00:20 /usr/bin/ghc-pkg-6.12.1
>

The ghc-config Bash script in multi-ghc uses symlinks to determine which is
the "current" version to use. The instructions on the GitHub page explain it
in detail, but here's how my setup works.

* I create /opt/ghc for storing GHC, clone the multi-ghc repository (or copy
the files) here.
* I create /opt/ghc/6.10.4/src, download
http://www.haskell.org/ghc/dist/6.10.4/ghc-6.10.4-i386-unknown-linux-n.tar.bz2,
and untar it here.
* cd ..; ln -s ../Makefile; make install

ghc-config creates a $HOME/.ghc-config directory for tracking the current
version and symlinks. Now, the key for your situation (I think) is your
$PATH. If you append $HOME/.ghc-config/ghc/bin to your $PATH after /usr/bin,
then you can use ghc-6.10.4 to call this specific version.

Unfortunately, there is still a problem. ghc-config also manages
$HOME/.cabal as a symlink for the current version. So, that would most
likely conflict with your setup. There may be a way to fix that, though I
haven't looked into it, or I could separate the cabal configuration from the
ghc configuration.


> If so, I think I'm going to use this tools since I occasionally like
> to try out ghc-HEAD.
>

multi-ghc should also work for doing this. As long as you install it as
/opt/ghc/6.13.blah (or whichever directory you want to use instead of
/opt/ghc). This was one of the goals of the design.

There's more documentation in the README.md and scripts. I'm happy to
improve upon it if something doesn't work.

Sean
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100408/5643abe7/attachment-0001.html


More information about the Haskell-Cafe mailing list