31

I just installed Haskell from it's official site. After that, following it's quick-start tutorial.

I run:

cabal update

Which shows this message:

Downloading the latest package list from hackage.haskell.org
Note: there is a new version of cabal-install available.
To upgrade, run: cabal install cabal-install

I run:

cabal install cabal-install

and check if the update was successful with

cabal update

The result, it shows me the same message from the start:

Downloading the latest package list from hackage.haskell.org
Note: there is a new version of cabal-install available.
To upgrade, run: cabal install cabal-install

So, did I upgrade the cabal-install or not? How do I check my cabal's version?

Important: I'm using the 64 bits version for Mac OS X.

MasterMastic
  • 20,711
  • 12
  • 68
  • 90
Luis Ortega Araneda
  • 865
  • 1
  • 12
  • 26
  • 3
    Use `which cabal` to find out which install of cabal you're using, cabal probably isn't installing the newly downloaded version to your PATH. Check ~/bin for another cabal executable. – bisserlis Feb 17 '13 at 07:12

9 Answers9

29

In my case (and probably others?) cabal is initially installed in /usr/local/bin by homebrew when installing haskell-platform. When upgrading cabal, the version is installed to $HOME/.cabal/bin/cabal. You ought to place your cabal bins higher in your $PATH, like so:

export PATH=$HOME/.cabal/bin:$PATH
Charles
  • 6,199
  • 6
  • 50
  • 66
  • This didn't work for me on homebrew+mavericks. [This](http://stackoverflow.com/a/19736802/388010) answer did, though. – Sebastian Graf Feb 18 '14 at 23:37
  • @Sebastian - Right - IF you're using the package directly from http://hackage.haskell.org/platform/. Homebrew uses `$HOME/.cabal` and `/usr/local/bin`, as opposed to `/Library/Haskell/bin`. I realize now that the solution above answers a slightly different question than the one the OP asked. – Charles Apr 15 '14 at 18:28
  • This was the issue for me. – Shon Nov 12 '14 at 21:16
  • So... Did the original installation just become obsolete then? – xji Apr 26 '15 at 12:43
19

I had a similar issue after installing the Haskell platform 2012.4.0.0 on OSX. When I ran cabal install cabal-install, it ended with:

cabal: ../ghc-7.4.2/lib/cabal-install-1.16.0.2/bin/cabal: does not exist

So I guessed it got its paths mixed up somewhere. However the executable was actually built successfully (check for ~/Library/Haskell/ghc-7.4.2/lib/cabal-install-1.16.0.2/bin/cabal) and I just copied it from there to ~/Library/Haskell/bin which is on my path.

Thereafter everything ran OK:

$ which cabal
/Users/luke/Library/Haskell/bin/cabal
$ cabal update
Downloading the latest package list from hackage.haskell.org
$ cabal --version
cabal-install version 1.16.0.2
using version 1.16.0.3 of the Cabal library
Shaun the Sheep
  • 22,353
  • 1
  • 72
  • 100
  • 2
    A similar situation occurred on my Windows system. The per-user cabal install directory will be in `%HOMEPATH%\AppData\Roaming\cabal\bin`, so this needs to be appended to the path as a higher priority. – Will Sewell Aug 08 '14 at 21:36
12

Everyone seems to experience a slightly different issue here. In my case, cabal was built successfully and installed to ~/Library/Haskell/bin.

As noted in ~/.cabal/config, adding ~/Library/Haskell/bin to PATH solved the issue.

Below is the description in ~/.cabal/config:

-- === Built executables will be installed in:
--     ~/Library/Haskell/bin
--
-- You may wish to place this on your PATH by adding the following
-- line to your ~/.bash_profile:
--     export PATH="$HOME/Library/Haskell/bin:$PATH"
Handol Park
  • 121
  • 1
  • 4
10

On OS X 10.8 I had to add /Library/Haskell/bin to my PATH (put it before /usr/bin). Adding that fixed the error message

Jay Dorsey
  • 3,563
  • 2
  • 18
  • 24
  • 1
    This is right.The old version in `/usr/bin` shadowed the version in `/Library/Haskell/bin`. Quite a messy installation I'd say... Why don't they just replace the old version in `/usr/bin`. – xji Jul 29 '15 at 08:48
3

cabal --version gives you the version of cabal you're running. If you want to see the version of cabal-install you have, run cabal info cabal-install and look at the versions installed line.

For me on OS X, versions installed is [unknown], after running cabal install cabal-install, which is not great.

Chris Barrett
  • 3,383
  • 17
  • 21
  • Maybe because it's uknown it always tells you tu upgrade? – Luis Ortega Araneda Feb 17 '13 at 11:40
  • 2
    @LuisOrtegaAraneda No, the cabal binary knows its version, it only tells you to upgrade if there is a newer one on hackage. Probably, the new one was installed in a directory not in your path. Which OS? On Linux (and OS X, iirc), you should add `$HOME/.cabal/bin` to your path; on Windows, something like `Users\You\AppData\Roaming`. – Daniel Fischer Feb 17 '13 at 14:21
  • Actually, it doesn't work with that path, in OS X you have to use `/Library/Haskell/`. And, when I do cabal info cabal-install it says `[unknown]` – Luis Ortega Araneda Feb 17 '13 at 15:03
3

I had this problem too.

After running which cabal, I found that it was using /usr/bin/cabal. Deleting this solved the problem.

Matthew H
  • 5,831
  • 8
  • 47
  • 82
1

It seems that cabal by default installs packages locally for the current user and therefore will not be part of the PATH. Look at the Cabal documentation specifically step 1.2.1 where you can change the configuration to install things globally by default (not recommended).

The way I installed cabal was cabal --global install cabal-install but still had problems with the path which since the default installation of Haskell puts the path in this order C:\Program Files\Haskell Platform\2013.2.0.0\lib\extralibs\bin;C:\Program Files\Haskell Platform\2013.2.0.0\bin; where the first path has precedence over the second one. With the --global flag cabal installed the binary to C:\Program Files\Haskell\bin which isn't in my path but must be added before the C:\Program Files\Haskell Platform\2013.2.0.0\lib\extralibs\bin path.

Taken from the documentation

You must put the cabal.exe in a directory that is on your %PATH%, for example C:\Program Files\Haskell\bin.

Har
  • 3,727
  • 10
  • 41
  • 75
1

In my case, a combination of several answers here was required to get through this issue. I'll attempt to provide a more comprehensive solution in one answer for anyone else in my situation.

  • For starters, running which cabal showed me that /usr/bin/cabal was being loaded, which was a symlink to /Library/Haskell/ghc-7.8.3-x86_64/bin/cabal. I believe newer versions of cabal were being installed, but this path was specific to a single version so they were ignored. Adding /Library/Haskell/bin to the front of my $PATH remedied that situation.
  • Second, and more importantly, the new versions of cabal-install were being installed into my cabal sandbox instead of the system location. I didn't see any other answers suggesting this, but after a little monkeying around I found that moving outside of my application's directory allowed cabal to actually install to the system.
  • Finally, adding the --global flag to the command fixed the problem. My final command was cabal install --global cabal-install. After this, I was finally able to update properly.

TL;DR: if you use cabal sandboxes, move outside the directory of your project and run cabal install --global cabal-install. Also, check your $PATH variable as others have suggested.

MacKinley Smith
  • 113
  • 3
  • 10
0

In my case the new version of cabal was being installed in the .cabal-sandbox of the project I was in.

e.g. Checking the version:

./.cabal-sandbox/bin/cabal --version

So I needed to upgrade it outside of that. This was on OSX.