I'm a newbie to haskell and cabal, so I'm probably missing something simple.
I updated cabal-install:
sudo cabal install cabal-install
Password:
Resolving dependencies...
Configuring cabal-install-1.22.0.0...
Building cabal-install-1.22.0.0...
Installed cabal-install-1.22.0.0
Updating documentation index
However cabal --version
says:
cabal-install version 1.18.0.5
using version 1.18.1.4 of the Cabal library
What happened to cabal-install 1.22.0.0?
There are two ways of making cabal
install packages globally. Note that, as a result, cabal
may require sudo.
This command will install <PACKAGE>
globally:
$ cabal install <PACKAGE> --global
As a more general solution, edit the file ~/.cabal/config
and set user-install
to False
. This will automatically set the --global
flag so you can just write cabal install <PACKAGE>
without any worry. Here's a snippet of my config
file:
...
-- split-objs: False
-- executable-stripping: True
user-install: False
-- package-db:
-- flags:
...
You may also want to set root-cmd
to sudo
if it's not already, so that cabal
will automatically prompt for the root password when it encounters a permission problem.
There's some more info online here.
I see that there's an updated cabal at ~/Library/Haskell/bin
, so I could replace /usr/bin/cabal with a symbolic link to this copy or I could copy this binary to /usr/bin
.
I'm still interested if there is a more elegant/canonical way to make sure the new cabal is what gets used by default.
TLDR: Try running hash -r
Bash has a PATH hashtable that maps commands to the location of binaries. You may still have an old version of cabal installed somewhere in your PATH (possibly in a sandbox). Since cabal is not a new command, the hashtable will keep serving up the old version. hash -r
rebuilds the hashtable, so the shell will correctly find the new version (providing it appears earlier in your path than the old one).
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