Search code examples
cabalhaskell-platformcabal-install

Haskell platform on mac installs cabal in /usr/bin, but cabal install goes in ~/Library/Haskell


I’ve just installed the Haskell Platform on my Mac running Mavericks 10.9. The cabal version included (1.16) is out of date, and prompts me to run “cabal update” and then “cabal install cabal-install". Doing so installs cabal 1.20.0.3, but it installs in ~/Library/Haskell. This is not in my executable path, so further attempts to run cabal result in executing version 1.16 from /usr/bin, which was not updated.

I guess I could get around this by changing my executable path to include ~/Library/Haskell, with higher preference than /usr/bin. But I don’t really want to do this. And I don’t want to maintain multiple out of date versions of the software in hidden locations on my system. How do I get cabal to update the executable in the right place? Running with sudo did not help.

Edit: Updated my path, but somehow it still doesn’t work:

[76 of 76] Compiling Main             ( Main.hs, dist/build/cabal/cabal-tmp/Main.o )
Linking dist/build/cabal/cabal ...
Warning: No documentation was generated as this package does not contain a library. Perhaps you want to use the --executables flag.
Installing executable(s) in
/Users/lethe/Library/Haskell/ghc-7.6.3/lib/cabal-install-1.20.0.3/bin
Installed cabal-install-1.20.0.3
Updating documentation index /Users/lethe/Library/Haskell/doc/index.html
euclid:Public lethe$ which cabal
/Users/lethe/Library/Haskell/bin/cabal
euclid:Public lethe$ cabal --version
cabal-install version 1.16.0.2
using version 1.16.0 of the Cabal library 
euclid:Public lethe$ echo $PATH
/Users/lethe/Library/Haskell/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/usr/texbin

It claims it installed cabal 1.20.0.3 to ~/Library/Haskell, and since the path is updated, it claims it’s going to execute the version in ~/Library/Haskell, but it also claims the executed version is 1.16.0.2. What’s going on here?

I also tried ghc-pkg recache and cabal install cabal-install-1.20.0.3 (with version number specified), but executed version is still 1.16.0.2


Solution

  • According to 23skiddo at GitHub, the way to get cabal to install in the system-wide directory is cabal install --global. Also if your shell is executing the wrong path to an executable you probably need to clear the cache with hash -d cabal or hash -r.