Error in cabal-installing hspec - haskell

I'm trying to install hspec, but I'm getting this:
$ cabal install hspec
Resolving dependencies...
cabal: dependencies conflict: ghc-7.2.2 requires containers ==0.4.2.0 however
containers-0.4.2.0 was excluded because ghc-7.2.2 requires containers
==0.4.1.0
What does this even mean?
Also, using ghc 7.2.2, cabal 10.2.

It sounds like you somehow broke your GHC install. GHC 7.2.2 comes with containers-0.4.1.0 (the version of which is the same as for GHC 7.2.1). It might be possible to fix it, but if the global package setup is broken then it would probably be easiest to re-install GHC.
What does ghc-pkg list containers say?
If containers-0.4.2.2 is found only in the per-user install (i.e. the /home/clark/.ghc/${arch}-${os}-7.2.2/package.conf.d output), then rm'ing /home/clark/.ghc/ and re-installing all the packages you installed with cabal install will fix it.

Related

Could not find module `Control.Monad.State` after updating mtl

I wanted to use the Control.Monad.Except module, but it turned out I had an outdated mtl package (It caused an import error - I had an obsolete module Control.Monad.Error). So I did
sudo cabal install mtl
And it installed the 2.2.2 version. However, now I had two versions installed, 2.1.2 and 2.2.2 which still caused an import error. I followed instructions here and did
sudo ghc-pkg unregister --force mtl-2.1.2
to remove the old version. But now I get an error:
Could not find module `Control.Monad.State'
It is a member of the hidden package `monads-tf-0.1.0.2'.
Use -v to see a list of the files searched for.
ghc-pkg check outputs
There are problems in package HTTP-4000.2.17:
dependency "mtl-2.1.2-735d9c92b4f214d454fb5168bb1eb6ee" doesn't exist
There are problems in package fgl-5.5.0.1:
dependency "mtl-2.1.2-735d9c92b4f214d454fb5168bb1eb6ee" doesn't exist
There are problems in package cgi-3001.1.8.5:
dependency "mtl-2.1.2-735d9c92b4f214d454fb5168bb1eb6ee" doesn't exist
There are problems in package parsec-3.1.3:
dependency "mtl-2.1.2-735d9c92b4f214d454fb5168bb1eb6ee" doesn't exist
There are problems in package regex-base-0.93.2:
dependency "mtl-2.1.2-735d9c92b4f214d454fb5168bb1eb6ee" doesn't exist
The following packages are broken, either because they have a problem
listed above, or because they depend on a broken package.
HTTP-4000.2.17
fgl-5.5.0.1
cgi-3001.1.8.5
parsec-3.1.3
regex-base-0.93.2
network-2.4.1.2
regex-compat-0.95.1
regex-posix-0.95.2
What should I do now?
You need to reinstall all the packages that depend on mtl to get them up to date with the new version. Cabal-install should be able to do that automatically if, in your project folder with the yourproject.cabal file, you do
$ cabal install --dependencies-only
As Daniel remarks, it may also be necessary to add --reinstall, namely if Cabal-install hasn't properly caught on to the dependency changes and needs to be manually ticked onto rebuilding them. If it thinks the reinstalls themselves might break yet other packages, --force-reinstalls may be needed too.
An alternative that avoids dependency hell is using the new Nix-style commands, which never break anything when reinstalling.

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!

Cabal: Blocking base packages from installing

I'm using cabal-install 1.14.0 on Ubuntu 12.04, and ghc 7.4.1.
Some cabal packages I try to install are pulling in directory-1.2.0.0, which requires ghc 7.6. Is there a way to configure cabal to not even attempt to install directory-1.2.0.0?
You can use a constraint,
cabal install foo --constraint="directory < 1.2"
or, as Daniel Wagner reminded me, better, since it really prevents reinstalls,
cabal install foo --constraint="directory installed"
and if you want that globally, add that to your cabal config file (~/.cabal/config on Linux and Mac, Somewhere in \Users\You\AppData on Windows, iirc), that has a line
-- constraint:
uncomment that and add the constraint.

installing dependencies in haskell

I was trying to install cabal-dev in my mac. After cloing, I tried to run ./bin/build. to get this error message.
cabal: cannot configure cabal-dev-0.9.1. It requires MonadRandom ==0.1.*, tar
==0.3.*, test-framework >=0.3 && <0.6 and test-framework-hunit >=0.2
There is no available version of MonadRandom that satisfies ==0.1.*
There is no available version of tar that satisfies ==0.3.*
There is no available version of test-framework that satisfies >=0.3 && <0.6
There is no available version of test-framework-hunit that satisfies >=0.2
What's wrong with this? How do I install the dependency files in Haskell?
I downloaded and installed from Haskell platform.
You don't have to use that build script; you can install cabal-dev just by running cabal install cabal-dev, which will automatically download and install cabal-dev and its dependencies.
But if you do want to use it, try cabal install --only-dependencies in cabal-dev's source directory first (the one with cabal-dev.cabal in it). That script's purpose is to avoid avoid installing into the global and user package databases — basically, it uses the same sandboxing cabal-dev itself does. It's probably not worth the effort, since cabal-dev installs just fine like every other program.
Issue the command cabal install cabal-dev. It will resolve the dependencies for you, assuming you have the standard cabal dist.

cabal install yesod fails?

Haskell package dependencies continue to be a problem but I don't know how to get around this one. My environment:
Ubuntu 10.10, new install
apt-get install ghc6 cabal-install
cabal update && cabal install cabal-install
Then:
cabal install yesod
And I get this:
$ cabal install yesod
cabal: Error: some packages failed to install:
persistent-0.3.1.2 failed during the building phase. The exception was:
ExitFailure 1
yesod-0.6.6 depends on persistent-0.3.1.2 which failed to install.
$ cabal install persistent-0.3.1.2
Resolving dependencies...
cabal: cannot configure blaze-builder-0.2.0.2. It requires text ==0.10.*
For the dependency on text ==0.10.* there are these packages: text-0.10.0.0,
text-0.10.0.1 and text-0.10.0.2. However none of them are available.
text-0.10.0.0 was excluded because enumerator-0.4.3.1 requires text ==0.11.*
text-0.10.0.1 was excluded because enumerator-0.4.3.1 requires text ==0.11.*
text-0.10.0.2 was excluded because enumerator-0.4.3.1 requires text ==0.11.*
How do I get yesod installed?
To see more details, add -v (or even -v2 or -v3) and perhaps --dry-run. Also it's useful to see what's currently installed, with ghc-pkg list.
When you upgrade persistent, cabal decides it should also rebuild your existing yesod which depends on it. This triggers a blaze-builder upgrade. blaze-builder requires an older text than enumerator which is also being installed.
http://hackage.haskell.org/package/enumerator claims to support older text versions as well as 0.11. But cabal has been outwitted somehow. The verbose output may tell more, or see if you can help it along with a --constraint or two. Or by first uninstalling some related packages, like yesod. And of course be sure you have done cabal update.
yesod is under heavy development. email michael snoyman (contact info can be found here), he is very responsive to requests
There is a dependency-break. Report this as an error to the author of the package. Consider downloading and installing an older version of enumerator manually, too.
I found some information about a better install process here:
https://github.com/yesodweb/yesod
Look for the section about cabal-src.
I'm in the process of trying it out.
I'll report back, and let people know if it works.

Resources