Search code examples
haskellcabaldarcs

Darcs installed with cabal not registered as shell command


As a part of installing Ubuntu on my computer, i apt-get installed cabal. After running cabal update, i ran cabal install darcs, discovered that i needed curses, installed libncurses5-dev, discovered that i needed curl, installed that, and when it still didn't work, ran cabal install darcs -f-curl.

This worked, but darcs doesn't run from the shell when just running darcs. It was installed in ~/.cabal/bin/darcs, so i made a link from there to /bin. Darcs now works from the shell, but i am left wondering if there is a better way to do it, perhaps running cabal install under sudo?


Solution

  • 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.