relocatable packages: GHC_PACKAGE_PATH and package.conf

Duncan Coutts duncan.coutts at
Mon May 28 16:24:09 CEST 2012

On 28 May 2012 05:36, Tim Cuthbertson <tim at> wrote:

>  - ghc doesn't seem to support ${pkgroot} prefixes. I thought it did,
> but I'm new to this so I may be misunderstanding where they can be
> used.

I thought it did too since I think I wrote the code for it. I don't
recall exactly what version it got into, it may well have been only

> Additionally, the paths that come out of cabal build have the compiler
> name and version hard coded, e.g lib/packagename/ghc-7.0.4/*. Is there
> any way to configure how this path is constructed to get rid of the
> ghd-7.0.4 part?

By default, yes, cabal produces absolute packages. It does have
support for relocatable packages on some compiler/platform combos:

sadly ghc on unix is not one of them because we do not have a reliable
way to find the program location (needed to find data files etc).
Actually more specifically it's not easy and nobody has implemented
it, rather than it being impossible.

So at the moment you could work around it in specific cases by hacking
the package registration info before registering. Do something like:
cabal copy --destdir=...
cabal register --gen-pkg-config=blah.pkg
sed -i =e '...' blah.pkg

Obviously your app/library had better not use the Cabal-provided
functions for finding data files at runtime since that'll get

If you want a proper solution you'll have to help us implement the
Cabal prefix independence feature for the ghc/unix combo.


More information about the Glasgow-haskell-users mailing list