Take the 2-minute tour ×

I installed a custom Haskell toolchain with the prefix $HOME/usr, so the compiler lives in $HOME/usr/bin/ghc and the documentation in $HOME/usr/share/doc/ghc/.... The toolchain consists of a ghc installation, a cabal installation and all the libs you need. I set up $PATH in a way, that all these programs are in it. There is no other installation of these tools on my system.

Now I tried to install some other libraries. But I always got the same error when cabal tried to install the documentation:

~$ cabal install --global binary
Resolving dependencies...
Configuring binary-
Preprocessing library binary-
Building binary-
 ... snip ...
Registering binary-
cabal: /usr/local/share/doc: permission denied

How can I tell cabal where the documentation should live? I don't want to give this information again and again in the shell, so the best would be a config file. I want to have all the haskell related stuff in my home tree, to avoid destroying my system with a wrong command.

share|improve this question
add comment

3 Answers

up vote 6 down vote accepted

Why are you installing with "--global"? By default this would put everything in /usr/local/. If you do a standard per-user install the docs will be installed into your home directory and it should work fine.

That being said, this is configurable via a file. The cabal config file is typically located at ~/.cabal/config/. Here's the relevant section of mine:

install-dirs global
  -- prefix: /usr/local
  -- bindir: $prefix/bin
  -- libdir: $prefix/lib
  -- libsubdir: $pkgid/$compiler
  -- libexecdir: $prefix/libexec
  -- datadir: $prefix/share
  -- datasubdir: $pkgid
  -- docdir: $datadir/doc/$pkgid
  -- htmldir: $docdir/html
  -- haddockdir: $htmldir

You can make whatever changes you like, just be sure to uncomment the lines. There is also an "install-dirs user" section, which is used in per-user installs.

share|improve this answer
add comment

I agree with the poster. Why is there no clear documentation for how to do cabal install package --global that prompts for sudo when permission is needed? Doing sudo cabal install package is a bad idea because then you're building packages as root. And you have to allow an internet connection to write to a file owned by root (you will have to populate /root/.cabal or something like that).

Here is a good reason why one would want to do this: If I install ghc and the haskell platform through my linux package manager (there are good reasons for this ;), then if I do cabal install package it will not recognize the packages that globally recognized.

share|improve this answer
I totally agree. –  FUZxxl May 14 '11 at 15:51
add comment

Well, someone actually posted a(n almost annoyingly) detailed description of how to do global installations (with either --global or install-dirs global) without running into permission errors. The trick is to use root-cmd sudo in the cabal config file. See, http://jdgallag.wordpress.com/2011/05/14/cabal-install-to-global-using-sudo-but-do-not-build-as-root/

share|improve this answer
add comment

Your Answer


