24

I am having lots of problems with cabal-install:
1: Every time I do cabal update, it tells me to do cabal install cabal-install, so I do, and then when I do cabal update again, it says the same thing.

2: When I try to install ghc-mod from hackage, it gives me this error:

[username@arch ~]$ cabal install ghc-mod
In order, the following will be installed:
haskell-src-exts-1.14.0 (reinstall) changes: pretty-1.1.1.1 -> 1.1.1.0
hlint-1.8.55 (reinstall)
ghc-mod-3.1.4
setup: The program happy version >=1.17 is required but it could not be found.
ghc-mod-3.1.4 depends on haskell-src-exts-1.14.0 which failed to install.
haskell-src-exts-1.14.0 failed during the configure step.
hlint-1.8.55 depends on haskell-src-exts-1.14.0 which failed to install.

So the problem was The program happy version >=1.17 is required but it could not be found., so I installed happy 1.19.2 using cabal install happy without problems.

I tried cabal install ghc-mod again, same error, so I tried cabal install haskell-src-exts --reinstall --force-reinstalls. It gave me the following error:

[username@arch ~]$ cabal install haskell-src-exts --reinstall --force-reinstalls
Configuring haskell-src-exts-1.14.0...
setup: The program happy version >=1.17 is required but it could not be found.
Failed to install haskell-src-exts-1.14.0
cabal: Error: some packages failed to install:
haskell-src-exts-1.14.0 failed during the configure step. The exception was:
ExitFailure 1

Basically The program happy version >=1.17 is required but it could not be found.. So happy is the problem again?

I have also tried downloading the tar.gz files from hackage and using cabal install on the .cabal file, also modified the .cabal file to ignore dependencies, still failed.

functorial
  • 687
  • 5
  • 13

2 Answers2

31

cabal install places executables in ~/.cabal/bin.

If you add it to your path, you will be able to use the new executables installed by cabal:

$ PATH=$HOME/.cabal/bin:$PATH
Alexis King
  • 43,109
  • 15
  • 131
  • 205
Etienne Laurin
  • 6,731
  • 2
  • 27
  • 31
  • 1
    Amazing. I just encountered two really weird things, so I write here in the case it would help someone. The first: I already had the `$HOME/.cabal/bin` in my $PATH, and… it didn't work! That only start working after I replaced the `$HOME` with `~` — really funny, because I used the variable being afraid that tilde won't work. The second thing: even after the system saw the path, and the *happy* — the *cabal* still didn't! Only after I executed the command from this answer, it start working. My guess is that *cabal* don't understand tilde either… – Hi-Angel Dec 06 '15 at 09:31
  • 1
    So, I guess the problem is like this: *cabal* wants a full path. So, after I added in my `/etc/environment` in the $PATH the `:$HOME/.cabal/bin` *(either the variant with tilde)*, the *cabal* in both cases thinks that *tilde* or the *$HOME* is part of the path *(it is valid path either)*. To get it working one have to write into the `/etc/environment` the full path till the directory with binaries. – Hi-Angel Dec 06 '15 at 09:36
23

I encountered with same problem and I solved the problem with installing happy package(confusing package name). So install it with your package manager(apt-get, pacman etc) before install package with cabal. This should be fix the problem.

Mesut Tasci
  • 2,970
  • 1
  • 30
  • 36
  • 1
    On a clean install from source of GHC/cabal (no Haskell Platform), installing this fixed a nondescript `ExitFailure 1` failure. – Elliot Cameron Jul 18 '14 at 21:43
  • 3
    I was able to fix this by `cabal install happy`. – connorbode Sep 07 '16 at 14:26
  • Installing with package manager messed things up in the past for me on Ubuntu. The big problem is apt-get installs one kind of Haskell module but then you start using cabal and you get different versions of the module. Dependency hell conflicts. So the suggestion by @connorbode is best. Using cabal gives you the latest, synchronized version. – Rick Majpruz Oct 27 '17 at 23:11