Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"cabal install cabal-install" doesn't update cabal version in OSX

Tags:

haskell

cabal

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?

like image 360
daj Avatar asked Jan 07 '15 18:01

daj


3 Answers

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.

like image 173
AJF Avatar answered Nov 06 '22 23:11

AJF


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.

like image 30
daj Avatar answered Nov 06 '22 22:11

daj


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

like image 25
eigensheep Avatar answered Nov 06 '22 22:11

eigensheep