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-0.5.0.2... Preprocessing library binary-0.5.0.2... Building binary-0.5.0.2... ... snip ... Registering binary-0.5.0.2... 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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With