Domanda

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?

È stato utile?

Soluzione 2

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.

Altri suggerimenti

cabal by default installs without needing administrator privileges. As such, it can't install into e.g. /usr/bin. Since $HOME/bin isn't a standard, the compromise is to put executables into ~/.cabal/bin.

You can then add ~/.cabal/bin to your path to see these executables (e.g. by appending the following to your .bashrc:

 export $PATH=$PATH:~/.cabal/bin

If you have admin privledges in your machine, by all means use the --global flag.

The --global flag is what is needed in this case. Running sudo cabal install darcs -f-curl --global, with -f-curl because cabal couldn't find curl, --global to make it install into usr/local/bin, and sudo just to be sure, works.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top