Firstly, do not use sudo
. Even when run under root, cabal
builds stuff in your home directory, so using sudo
indiscriminately can lead to root-owned files in your ~/.cabal
. Instead, set root-cmd: sudo
in your /.cabal/config
, then cabal
with the --global
option will invoke that command as appropriate.
Secondly, using local installs is generally more convenient and safer than using global ones, because you keep your package manager and cabal
separate. So you could just as well add this to your ~/.bashrc
:
export PATH=$HOME/.cabal/bin:$PATH
and then continue to install stuff without using sudo
at all.
See also: a slightly over-pessimistic, but nevertheless informative article on cabal package management.