Skip to content


Subversion checkout URL

You can clone with
Download ZIP


ghc global package db should live in /var not /usr #536

bos opened this Issue · 5 comments

2 participants


(Imported from Trac #543, reported by nr on 2009-04-19)

cabal requires root privileges in order to modify files in /usr/lib/ghc-6.8.2. I'm reporting this as a defect in the tool, since it was told to install in /usr/local/cabal, and it seems unreasonable that cabal should require root privileges when these are not required for installing into its target directory.

I am less well informed about the Linux Filesystem Standard, but I believe that files in /usr/lib are supposed to be immutable. If I'm correct, cabal is violating that standard in a major way. If you must have a mutable package.conf, put it in /var/lib/ghc-6.8.2, and make it group writable by a suitable group (which you may need to create). I'm cc-ing ghc-devel on this one because the two groups will probably have to cooperate.

: nr@homedog 5548 ; cabal install graphmod
Resolving dependencies...
Downloading dotgen-0.2...
Configuring dotgen-0.2...
Preprocessing library dotgen-0.2...
Building dotgen-0.2...
[1 of 1] Compiling Text.Dot         ( Text/Dot.hs, dist/build/Text/Dot.o )
/usr/bin/ar: creating dist/build/libHSdotgen-0.2.a
Installing library in /usr/local/cabal/lib/dotgen-0.2/ghc-6.8.2
Registering dotgen-0.2...
Reading package info from "dist/installed-pkg-config" ... done.
Unable to rename "/usr/lib/ghc-6.8.2/package.conf" to "/usr/lib/ghc-6.8.2/package.conf.old"
Saving old package config file... ghc-pkg.bin: /usr/lib/ghc-6.8.2/package.conf: renameFile: permission denied (Permission denied)
Downloading haskell-lexer-1.0...
Configuring haskell-lexer-1.0...
Preprocessing library haskell-lexer-1.0...
Building haskell-lexer-1.0...
[1 of 6] Compiling Language.Haskell.Lexer.Position ( Language/Haskell/Lexer/Position.hs, dist/build/Language/Haskell/Lexer/Position.o )
    Warning: Pattern match(es) are overlapped
             In a case alternative: '\n' -> ...
[2 of 6] Compiling Language.Haskell.Lexer.Tokens ( Language/Haskell/Lexer/Tokens.hs, dist/build/Language/Haskell/Lexer/Tokens.o )
[3 of 6] Compiling Language.Haskell.Lexer.Utils ( Language/Haskell/Lexer/Utils.hs, dist/build/Language/Haskell/Lexer/Utils.o )
[4 of 6] Compiling Language.Haskell.Lexer.Lex ( Language/Haskell/Lexer/Lex.hs, dist/build/Language/Haskell/Lexer/Lex.o )
[5 of 6] Compiling Language.Haskell.Lexer.Layout ( Language/Haskell/Lexer/Layout.hs, dist/build/Language/Haskell/Lexer/Layout.o )
[6 of 6] Compiling Language.Haskell.Lexer ( Language/Haskell/Lexer.hs, dist/build/Language/Haskell/Lexer.o )
/usr/bin/ar: creating dist/build/libHShaskell-lexer-1.0.a
Installing library in /usr/local/cabal/lib/haskell-lexer-1.0/ghc-6.8.2
Registering haskell-lexer-1.0...
Reading package info from "dist/installed-pkg-config" ... done.
Unable to rename "/usr/lib/ghc-6.8.2/package.conf" to "/usr/lib/ghc-6.8.2/package.conf.old"
Saving old package config file... ghc-pkg.bin: /usr/lib/ghc-6.8.2/package.conf: renameFile: permission denied (Permission denied)
cabal: Error: some packages failed to install:
dotgen-0.2 failed during the final install step. The exception was:
exit: ExitFailure 1
graphmod-1.1.3 depends on haskell-lexer-1.0 which failed to install.
haskell-lexer-1.0 failed during the final install step. The exception was:
exit: ExitFailure 1
: nr@homedog 5549 ;

(Imported comment by @dcoutts on 2009-04-19)

Right, the problem here is that we need root permissions so that ghc-pkg can modify ghc's global package db. This is one reason we do per-user installs by default.

You're quite right though that ghc should be keeping its package db in /var rather than in its install libdir. Ideally we should have a second "global" one in /usr/local/var corresponding to packages installed in /usr/local/lib.


(Imported comment by @dcoutts on 2009-04-21)

Changing title to reflect the real issue.

See also the ghc ticket that this depends on.


(Imported comment by Syzygies on 2009-12-22)

The real problem is accepting the dubious, ancient custom of scattering an installation across multiple bin, lib, share, doc directories rather than localizing everything in say /usr/local/ghc-7.0.4a. Giving the installing user write permission for this directory avoids the need for root permissions, and can insure that the install actually takes place exclusively within this directory.

I'm baffled how others do side-by-side installs of different versions of GHC without following such a scheme. I'm opposed to this /var proposal. The convention of spraying files across hell and high water is what's broken, and we should do nothing to make matters worse. Adding /var to the spray list would be making matters worse.

A number of modern projects similar to GHC default to localized installs in the style of /usr/local/ghc-7.0.4a; we should do the same. GHC is important enough to warrant a separate PATH entry, or aliases in /usr/local/bin.

"This is one reason we do per-user installs by default."

Cabal should check for a global config file parallel to which ghc according to the current path, defaulting to global installs and ignoring ~/.cabal/config if possible. The existence of ~/.cabal/config is like a global variable, and interferes with multiple side-by-side installations of GHC.


(Imported comment by @dcoutts on 2011-06-24)

Note of course that following the ./configure file layout convention and having relocatable packages are orthogonal. It is still possible to ./configure and put everything under one prefix (e.g. /opt/ghc-x.y/).

Then whether ghc defaults to one or the other scheme is up to the packager. Generic binary tarballs should probably be relocatable and self contained, while Linux distros will continue to use their current scheme.

@ttuegel ttuegel added the invalid label

This is not a Cabal issue; the relevant GHC issue is even linked!

@ttuegel ttuegel closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.