Cabal can't determine GHC version - haskell

I am currently trying to update Cabal (1.14.0, cabal-install at version 0.14.0) by doing
cabal install cabal-install
However, this gives me an ExitFailure1 with the error
setup: The program ghc version >=6.4 is required but the
version of /usr/bin/ghc could not be determined.
But I'm definitely running a version of GHC that is greater than that.
$ /usr/bin/ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.4.2
It might be important that I'm on OSX 10.8 and that I installed Haskell through the Haskell Platform download for Mac.
Does anyone have advice on how to fix or work around this issue? I haven't been able to find any documentation on this problem.

Since you're on a Mac, why not try installing the excellent Homebrew package manager? Add /usr/local/bin to your PATH, and then it's just brew install cabal-install.
You can even brew install ghc haskell-platform.
To upgrade the package list, use brew upgrade, then you can see what needs updating with brew outdated and update them with brew update.
Of course, you can name individual packages to update also, and specify versions of packages. Homebrew keeps the "recipes" (Ruby scripts) for package management in its own git repository (by default in /usr/local).
Then you can get on with what you really wanted to do in the first place...write some code! (or build, in your case)

Related

cabal install ghc impossible happened: heap overflow

I'm trying to follow along with the Plutus Pioneer lectures, and I'm getting this error
My system:
Ubuntu Linux Docker image running on MacOS.
I installed the Haskell package on the image from here: https://www.haskell.org/platform/linux.html
using this line in my Dockerfile: RUN apt-get install -y haskell-platform
This seems to install Cabal version 2.4.
When I clone the code repository for the lectures: https://github.com/input-output-hk/plutus-pioneer-program and then go to the week01 directory and try cabal build like in the lecture, I get dependencies not found errors. The first missing dependency is 'aeson', which seems to install if I run cabal install aeson.
The subsequent build attempts fail on dependency 'base' being the wrong version.
Then I thought maybe if I update Cabal to version 3.4 it might help, so I tried cabal install cabal-install, but this also has errors:
Theexception was:ExitFailure (-9)
This may be due to an out-of-memory condition.
So I googled some more and tried this command line: cabal install --ghc-options="+RTS -M600M" -j1 cabal-install from here https://stackoverflow.com/a/46148345/52236
This seems to get further, but now I'm at this error:
ghc: panic! (the 'impossible' happened)
(GHC version 8.6.5 for x86_64-unknown-linux): heap overflow
If anyone has any idea how to fix this it would be appreciated. Do I need to add more RAM to my Docker Ubuntu image? It currently has 1.9GB of memory and 1.7GB free.
thanks,
m
I fixed this by increasing the RTS param:
cabal install --ghc-options="+RTS -M1000M" -j1 cabal-install
Well, actually it compiled everything, but cabal --version still says 2.4, not 3.4. There was this warning too:
Warning: could not create a symlink in /root/.cabal/bin for cabal because the
file exists there already but is not managed by cabal. You can create a
symlink for this executable manually if you wish. The executable file has been
installed at /root/.cabal/bin/cabal

cabal-install and ghc 7.10.1

I just upgraded to ghc 7.10.1 and whenever I try use cabal-install I run into the following error:
ghc: ghc no longer supports single-file style package databases (dist/package.conf.inplace) use 'ghc-pkg init' to create the database with the correct format.
How do I fix this?
If you are on Mac OS X and are using homebrew it may be that you installed Cabal through haskell-platform package, which is outdated with no direct upgrade path.
You should uninstall haskell-platform and reinstall Cabal using the cabal-install package.
It could well be you have a newer cabal on your path but can't find it because the old one shadows it. So looking for where cabal may help you resolve that. Barring that, you can download a newer cabal binary from the cabal homepage.

Cabal install hoogle not working

I need to configure eclipsefp and install hoogle and scion-browser for setting up a haskell project using mysql.
I tried to install hoogle and scion-browser from Eclipse -> Preference -> Helper executable, and also from the terminal, however unsuccessfully.
cabal install hoogle
and
cabal install scion-browser
fail, throwing the following:
cabal:codec.compression.zlib: premature end of compressed stream.
Edit:
It may be a problem with the cabal version?
If I run cabal --version in terminal, it says:
cabal-install version 0.14.0
using version 1.14.0 of the Cabal library
If I perform cabal update nothing happens.
However, in Eclipse -> Helper Executables there are two versions available:
version 0.14.0
version 1.18.0.2
They are located at different locations, I checked the second one to be used.
in my case, the downloaded package is broken, figured it out by running cabal install -v package-name, removed it manually and finally worked

I updated ghc to a new version, how do I automatically reinstall all cabal packages?

For instance, I've just updated ghc from 7.6.2 to 7.6.3 and would like just reinstall all the packages I had previously installed.
Running
cabal install world
will install all the previously installed packages. Some packages might not install, in which case one can delete them from ~/.cabal/world and run the command again, and install them again later when they are working again with that version of ghc.

cabal-install and Debian

So, this is a bit of a personal problem, but maybe people will have good advice or workarounds.
The problem is about installing cabal-install and haskell-platform under Debian.
When you apt-get install haskell-platform, it ships with cabal-install, and its command cabal is available.
Now this cabal-install is not up-to-date:
> which cabal
/usr/bin/cabal
> /usr/bin/cabal --version
cabal-install version 0.8.0
using version 1.8.0.2 of the Cabal library
But, my understanding of running cabal update is that it updates cabal, but since it is not a "Debian thingy", it puts it in ~/.cabal/bin/.
> ~/.cabal/bin/cabal --version
cabal-install version 0.8.2
using version 1.8.0.2 of the Cabal library
Now my system has 2 cabals, and the one I get by typing cabal is not the one I want to use... Because it'll keep updating the other one instead of itself, and is therefore ineffective.
So what I did was I aliased it in my ~/.bashrc:
alias cabal='~/.cabal/bin/cabal'
Now:
> cabal --version
cabal-install version 0.8.2
using version 1.8.0.2 of the Cabal library
So, my final questions:
Is there a deb repository that holds cabal 0.8.2?
Could my current solution lead to problems? (For instance, which cabal still points to my useless /usr/bin/cabal, so if scripts use this command they'll get fooled...)
Did someone come up with a better solution? (Mine is a bit ad-hoc but that's all I could come up to with my poor knowledge of what is happening behind the scenes...)
Please correct me if anything I say above is wrong or inaccurate.
What I do is installing cabal with the --global flag. This will install cabal into /usr/local/bin/cabal, thus it will always superseed the Debian packages cabal.
Another way, is to generally avoid the Debian packages and install the Haskell platform straight from its source. This approach is also better, if you always want to have the latest releases of the Haskell libs.
I keep my user-local $HOME/.cabal/bin in the front of the PATH.
I install only ghc6, ghc6-prof, ghc6-doc and cabal-install from the distribution packages. I don't use distribution cabal-install for anything more than to bootstrap the new ~/.cabal.
All the rest I install with cabal install, including the newer cabal itself.
When I want to use newer GHC, I deploy it in /usr/local/stow/ghcVERSION, and enable it with GNU stow (it adds symlinks in /usr/local which, again, has precedence in my PATH). When I want to switch back to the distribution GHC I just run stow -D to remove all symbolic links to it.
I consider using cabal-dev to have project-specific cabal installations, and avoid broken dependencies which happen with cabal from time to time.
As a matter of fact I don't use Haskell Platform at all because I don't need all of it and find it easier to be able to install individual libraries. I do not install distribution libraries, because not all of them are available or are exactly the versions I need; and it is much easier to control conflicts if all of them are installed in the same place (~/.cabal in my case). I do not install anything with --global, because I think it is wrong and difficult to rollback.
Of course this information gets out of date, but yes, Debian unstable and testing have, at the time of writing, cabal-install 0.10.2.
Generally, the Debian packaging of Haskell stuff is aimed at users who want a set of packages that is known to work together, i.e. no dependency hell, at the expense of not always having the latest and greatest. This includes cabal-install. I use cabal-install from the repositories, and only to install those libraries that have not been packaged for Debian yet.
Disclaimer: I am one of the guys that create those packages for Debian.
On Ubuntu I also tend to install GHC via stow, ignoring the system packages altogether.
One slight twist from jetxee's approach is that I do install the Haskell Platform (from source), lumping it in with the GHC stow directory. I suppose I ought to call the paths /usr/local/stow/haskell-platform-VERSION, but I tend to use /usr/local/stow/ghc-VERSION instead.

Resources