change location of user's package directory

Albert Y. C. Lai trebla at vex.net
Fri Jul 26 00:02:05 CEST 2013


On 13-07-25 03:14 PM, harry wrote:
> How can I change the location that ghc and ghc-pkg use for the user's package
> directory? I'm running GHC in a very restricted environment where I don't
> have access to $HOME, but I can use specific subdirectories.

Cannot. But you have another option. GHC and cabal-install support 
further package databases than global and user.

To initialize:

     mkdir /joy (or other ways to make /joy exist and be empty)
     ghc-pkg --package-db=/joy recache

Note: two hyphens, -- not -


To cabal-install:

     cabal --package-db=/joy --prefix=/delight install acme-dont

Note: you must provide a custom --prefix. The default is $HOME/.cabal 
which is exactly what you can't use.


To ghc-pkg:

     ghc-pkg --global --package-db=/joy list
     ghc-pkg --package-db=/joy unregister acme-dont

However, beware of http://ghc.haskell.org/trac/ghc/ticket/5442


To ghc or ghci:

     ghc -package-db=/joy

Note: one hyphen: - not --
(Don't you love to memorize random conventions.)
(In older versions of GHC, it was even better:
     cabal --package-db=/joy
     ghc-pkg --package-conf=/joy
     ghc -package-conf=/joy
Don't you love to memorize random conventions.)

Read the full story in GHC User's Guide section 4.9 "Packages". It comes 
with GHC on your hard disk.




More information about the Glasgow-haskell-users mailing list