cabal-install and Debian - haskell

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.

Related

Which packages are hardwired into GHC?

While trying out the cabal sandbox I found that you cannot install different versions of base and some other packages in sandbox as pointed out in this answer.
I wonder which packages are hardwired into GHC. Is there a complete list somewhere?
I could not find it using google.
I don't just want to get the list of packages that gets installed with ghc. I want to know which packages are so intrinsic to GHC that you cannot install multiple versions of those packages even in a sandbox.
In other words, Which packages are not at all amenable to cabal sandbox?
If you run ghc-pkg list, there should be two lists of packages: those installed in /usr/local/lib/ghc (or wherever GHC is installed), and those in ~/.ghc/. The packages in /usr/local/lib/ghc come with GHC.

Failing to install Haskell uniplate library

I am trying to install Elm and the instructions are to install Haskell and then
sh> cabal update
sh> cabal install cabal-install
sh> cabal install -j Elm elm-repl elm-reactor elm-get
When I do, the cabal-install installation installs text-1.2.0.0 which conflicts with the text-1.1.0.0 which uniplate requires so uniplate and its dependents fail to install. Text-1.1.0.0 is installed and present but is rejected in favour of text-1.2.0.0, even though the target needs text-1.1.0.0.
Is there a way to insist that cabal use text-1.1.0.0?
Is there a way to get text-1.1.0.0 and text-1.2.0.0 to co-exist?
Is there a way to convince uniplate that it can accept text-1.2.0.0?
Or a way to make uniplate (or cabal) believe that version text-1.1.0.0 is actually installed? Would that even work?
When I explicitly try to install version 1.1.0.0 of text, I am told that a reinstall would break other packages. Apparently it is a downgrade and not a co-installation. cabal does not seem to have an option to allow to me install two versions of the same library at the same time.
If I uninstall Haskell and all the libraries and then re-install Elm (without installing cabal-install so I don't get text-1.2.0.0 installed so there is no clash), I get 100 or so lines of
package aeson-0.7.0.4-8f84b14cc682e4c9b009352420076a45 is unusable due to missing or recursive dependencies:
attoparsec-0.10.4.0-ec2d0a330db1f6e3a6a3b79471a403ef hashable-1.2.2.0-45bd22df8c4ead6b3a7fb1d08bb07f7d mtl-2.1.3.1-8bcc0591131896cfc8761a93703d4c61 scientific-0.2.0.2-5e275f5d96527da6dc1f05642692a484 syb-0.4.1-be94ebe67c3607f5df1dfcc1906f5d5c text-1.1.0.0-9bd69e9ace700e05fb08e463086bc383 unordered-containers-0.2.4.0-69836b34d13649bcfacc8fb0c9f53e64 vector-0.10.9.1-c550551354bc7c2b5a1d261f39b2f3f4
package aeson-pretty-0.7.1-5dc26d5a4560afe110e90283479a1251 is unusable due to missing or recursive dependencies:
aeson-0.7.0.4-8f84b14cc682e4c9b009352420076a45
text-1.1.0.0-9bd69e9ace700e05fb08e463086bc383
unordered-containers-0.2.4.0-69836b34d13649bcfacc8fb0c9f53e64
vector-0.10.9.1-c550551354bc7c2b5a1d261f39b2f3f4
package asn1-encoding-0.9.0-94e9066cccf7ead73bee5ae4aa982071 is unusable due to missing or recursive dependencies:
mtl-2.1.3.1-8bcc0591131896cfc8761a93703d4c61
package asn1-parse-0.9.0-af4efc4777a8a0d9d19a626d5e4b08ff is unusable due to missing or recursive dependencies:
asn1-encoding-0.9.0-94e9066cccf7ead73bee5ae4aa982071
mtl-2.1.3.1-8bcc0591131896cfc8761a93703d4c61
text-1.1.0.0-9bd69e9ace700e05fb08e463086bc383
I have no idea at all how in resolve this or where to even try. Has anybody trod this path before and do you have any advice or pointers?
Thank you.
Edit
Installing in a sandbox changes the outcome only by degrees: text-1.1.0.0 does not clash with text-1.1.0.0 but still can not be loaded (despite being installed) and still remains the unsatisfied dependency.
blaze-builder is first to fail with cannot satisfy -package-id text-1.1.0.0-9bd69e9ace700e05fb08e463086bc383 yet the same log earlier stated [_12] trying: text-1.1.0.0/installed-9bd... (dependency of Elm-0.13) without apparent error or complaint.
cabal list shows both text-1.1.0.0 and text-1.2.0.0 as installed.
Installing blaze-builder separately looks the same. Dependency resolution shows
[_56] trying: blaze-builder-0.3.3.4 (user goal)
[_57] next goal: text (dependency of blaze-builder-0.3.3.4)
[_57] trying: text-1.1.0.0/installed-9bd...
[_58] done
All looks good but later, same log has
<command line>: cannot satisfy -package-id text-1.1.0.0-9bd69e9ace700e05fb08e463086bc383
(use -v for more information)
The ghc command line already had the -v flag and trying to re-run the command line copied from the log, with more -vs, gives an error with "can't find a package database at
dist/dist-sandbox-ad0bcd57/package.conf.inplace".
No package.conf.inplace seems to exist.
Further edit
On the Elm install page is a link to a BuildFromSource.hs script that is also supposed to work installing Elm. In the time that it took for that script to run and fail to work, I managed to install leiningen, node, npm, grunt and Clojure. I am now further along the road to getting Clojurescript installed in about 20 minutes than I am in getting Elm installed in nearly a week.
Elm looked really interesting but it is playing way too hard to get.
Thanks again to everyone who tried to help.
* Edit *
I finally got it.
Every executable installed by the installer at http://elm-lang.org/Install.elm caused a segfault.
The "Build from source" option at the same page did not work because the dependencies either stepped all over each other or could not get themselves straight in the first place.
The ghc at http://new-www.haskell.org/downloads/osx needs a later version of Mac OS than I have. (A link to older versions would not have gone astray.)
The solution (and it is obvious in retrospect) was to port install haskell-platform and port install hs-cabal-install and cabal install Elm .... I did have to run one of those installers twice because it could not find hackage.haskell.org (How is that a 'user' error?) but my hello-world.elm now compiles.
Thank you all again.
It looks like some dependency issues with elements you already have installed. You will probably need to install it in a sandbox.
First, update to the latest version of cabal:
$ cabal update
$ cabal install cabal cabal-install
Next, make sure you have the installed version of cabal on your $PATH.
$ which cabal
> /path/to/cabal/bin/cabal
If it says something like /usr/bin/cabal you will need to export cabal to be on your $PATH. For me this is `/home/username/.cabal/bin
$ export PATH=/path/to/cabal/bin/cabal;$PATH
Run which cabal again and ensure it is pointing to that path.
Now that you have the latest version of cabal. Run the following:
$ mkdir elm
$ cd elm
$ cabal sandbox init
This will initialize a sandbox where dependencies are completely independent of your other installs. Within this directory, you should be able to install the elm platform by running:
$ cabal install Elm elm-repl elm-reactor elm-get
These will be installed in a sub-directory called .cabal-sanbox/bin/ For convenience, you will probably want to add this to your $PATH so you can run the executables from any directory.
Hope this helps!

Can cabal find matching versions for given set of packages?

I'm in situation where I cannot install new package without reinstalling others (my distribution comes without sandbox).
Is it possible to determine which version of each package I should use so that there will be no conflicts with new one included?
How can I encode this set to create new cabal sandbox?
cabal install --dry-run --avoid-reinstalls should give you some output that indicates the installation plan for a particular package, or fail if it cannot avoid reinstalls due to dependencies.
However, sandboxes are really quite helpful. Independent of how you bootstrap your cabal installation (tarballs, distribution packages, etc.), you should probably add ~/.cabal/bin early in your path and then cabal install cabal-install. This should only fail if the latest version of cabal doesn't work on your version of ghc / base.

Cabal can't determine GHC version

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)

Reinstall behavior of cabal-dev

The latest cabal-install that I've been using (0.13.3, from the darcs repo) is nice; it lets you know when you might break your GHC installation with reinstalls. What I want to know is this: suppose a cabal install foo would perform a reinstall that would break my GHC. What would happen if I cabal-dev install foo instead? Would I be able to avoid breaking GHC? Could I actually make use of the foo package in a cabal-dev sandbox, or would it just be a broken sandbox?
Example: yesod, GHC 7.4.1, cabal-dev 0.9 built from github source, Cabal 1.14.0 library.
Just to clarify, if I am understanding you right, you are not breaking GHC in either case. I believe you are referring to installing a package, which then reinstalls one of the underlying dependencies of another package, therefore breaking that other package's dependency chain and preventing it from properly working/compiling when used. Simply removing .ghc from your home folder and re-doing cabal installs typically resolves this problem, albeit in a really painful way.
When you use cabal-dev, all the cabal install steps and ghc-pkg register steps are done in a local sandbox environment. Your global/user ghc packages are not at all touched. Since you typically instantiate one cabal-dev sandbox per project, clashes like described above don't typically happen.
To get to your question - it depends entirely on what is already installed in that particular cabal-dev sandbox. If there are no conflicts, it wouldn't break anything. If you are forcing a --reinstall, you might have to --reinstall any packages in the local cabal-dev sandbox that depend on the package you just reinstalled.
In any case, your GHC installation itself would not break (or be altered in any way) and you can always rm -rf cabal-dev under your project folder and redo cabal-dev install.
Hope this helps.

Resources