cabal dependency resolution fail for 'lens' - haskell

I just did a cabal update and tried to install 'lens' from hackage. That gave me the following error -
$ cabal install -j lens
Resolving dependencies...
Configuring dlist-0.7.0.1...
... <snip>
Configuring mtl-2.0.1.0...
Building mtl-2.0.1.0...
Failed to install mtl-2.0.1.0
Last 10 lines of the build log ( /home/aj/.cabal/logs/mtl-2.0.1.0.log ):
Building mtl-2.0.1.0...
Preprocessing library mtl-2.0.1.0...
[ 1 of 21] Compiling Control.Monad.Writer.Class (
Control/Monad/Writer/Class.hs, dist/build/Control/Monad/Writer/Class.o )
[ 2 of 21] Compiling Control.Monad.State.Class ( Control/Monad/State/Class.hs,
dist/build/Control/Monad/State/Class.o )
[ 3 of 21] Compiling Control.Monad.Reader.Class (
Control/Monad/Reader/Class.hs, dist/build/Control/Monad/Reader/Class.o )
[ 4 of 21] Compiling Control.Monad.RWS.Class ( Control/Monad/RWS/Class.hs,
dist/build/Control/Monad/RWS/Class.o )
[ 5 of 21] Compiling Control.Monad.Identity ( Control/Monad/Identity.hs,
dist/build/Control/Monad/Identity.o )
[ 6 of 21] Compiling Control.Monad.Error.Class ( Control/Monad/Error/Class.hs,
dist/build/Control/Monad/Error/Class.o )
Control/Monad/Error/Class.hs:93:18: Not in scope: `catch'
... <snip>
cabal: Error: some packages failed to install:
aeson-0.7.0.3 depends on mtl-2.0.1.0 which failed to install.
exceptions-0.6 depends on mtl-2.0.1.0 which failed to install.
free-4.7.1 depends on mtl-2.0.1.0 which failed to install.
lens-4.1.2 depends on mtl-2.0.1.0 which failed to install.
mtl-2.0.1.0 failed during the building phase. The exception was:
ExitFailure 1
So looks like mtl-2.0.1.0 is broken. However some more dependency tracking reveals that nothing in the lens package definition actually depends on that version of mtl. Infact, the next thing I tried was -
$ cabal install -j aeson
$ cabal install -j free
$ cabal install -j lens
And that succeeds without problems.
So why would cabal try to install mtl-2.0.1.0 when installing lens directly? I've tried removing my .ghc and .cabal directories and repeating the steps, with the same results. The cabal version I'm using is 1.16 -
$ cabal -V
cabal-install version 1.16.0.2
using version 1.16.0 of the Cabal library

The workaround that I am using is to first install transformers-compat with the transformers 3 flag
$ cabal install -ftransformer3 transformers-compat
and then install lens with the transformers 0.3.0.0 constraint
$ cabal install --constraint="transformers==0.3.0.0" lens

I hit this error too. I think I've managed to fix it by manually unpacking mtl-2.0.1.0, explicitly adding catch to the import list of Control.Exception in Control/Monad/Error/Class.hs (L:55), then running cabal install.
After that I was able to run cabal install lens. I'd be interested to know if that works for you too!

Related

Haskell glib library wont build

When I install glib this is the error that I get. I think my problem has to do with the "legacy fallback" part but I have no way to fix that.
ghc version: 8.6.5
cabal version: 3.0.0.0
$ cabal install glib
Resolving dependencies...
Build profile: -w ghc-8.6.5 -O1
In order, the following will be built (use -v for more details):
- glib-0.13.8.0 (lib:glib) (requires build)
Starting glib-0.13.8.0 (all, legacy fallback)
Building glib-0.13.8.0 (all, legacy fallback)
Failed to build glib-0.13.8.0.
Build log (
/home/dagon/.cabal/logs/ghc-8.6.5/glib-0.13.8.0-83f4ff904d65860d6da22747d08c5e962bdbbd1be59c0e6934c51b56a26d7fa7.log
):
[1 of 1] Compiling Main ( /tmp/cabal-install.-14521/dist-newstyle/tmp/src-14521/glib-0.13.8.0/dist/setup/setup.hs, /tmp/cabal-install.-14521/dist-newstyle/tmp/src-14521/glib-0.13.8.0/dist/setup/Main.o )
Linking /tmp/cabal-install.-14521/dist-newstyle/tmp/src-14521/glib-0.13.8.0/dist/setup/setup ...
Configuring glib-0.13.8.0...
Preprocessing library for glib-0.13.8.0..
c2hs/c/CAST.hs:(1017,5)-(1069,22): Non-exhaustive patterns in function put_
cabal: Failed to build glib-0.13.8.0. See the build log above for details.
$ rm -rf ~/.cabal ~/.ghc
$ cabal upadte
$ cabal install glib

cabal reports "/usr/bin/ld: cannot find -lHSrandom-1.0.1.1-ghc7.8.3"

I have Ubuntu 14.04LTS. I downloaded the latest ghc-7.8.3 from http://www.haskell.org/ghc/download_ghc_7_8_3#x86_64linux and installed it to /usr/local.
Then I updated my cabal to version 1.20.0.3.
I typed cabal install QuickCheck into my terminal, and got:
Resolving dependencies...
Configuring tf-random-0.5...
Building tf-random-0.5...
Preprocessing library tf-random-0.5...
[1 of 4] Compiling System.Random.TF.Gen ( src/System/Random/TF/Gen.hs, dist/build/System/Random/TF/Gen.o )
[2 of 4] Compiling System.Random.TF.Init ( src/System/Random/TF/Init.hs, dist/build/System/Random/TF/Init.o )
src/System/Random/TF/Init.hs:94:5: Warning:
In the use of ‘bitSize’ (imported from Data.Bits):
Deprecated: "Use 'bitSizeMaybe' or 'finiteBitSize' instead"
[3 of 4] Compiling System.Random.TF.Instances ( src/System/Random/TF/Instances.hs, dist/build/System/Random/TF/Instances.o )
[4 of 4] Compiling System.Random.TF ( src/System/Random/TF.hs, dist/build/System/Random/TF.o )
/usr/bin/ld: cannot find -lHSrandom-1.0.1.1-ghc7.8.3
collect2: error: ld returned 1 exit status
Failed to install tf-random-0.5
cabal: Error: some packages failed to install:
QuickCheck-2.7.5 depends on tf-random-0.5 which failed to install.
tf-random-0.5 failed during the building phase. The exception was:
ExitFailure 1
BTW, I already have haskell-platform with ghc-7.6.3 installed via apt-get before.
I remember having a similar issue when setting up ghc-7.8. It has something to do with the new cabal, which somehow isn't compatible with libraries installed with an older versio (but it fails to give the correct problem reason.
Anyway, I think reinstalling the packages in question
cabal install random --reinstall --force-reinstalls
sets it up so cabal install tf-random should then succeed.

how to find where and why cabal fails - could not resolve dependencies

I tried to install few modules this morning to get Eclipse FP to work, scion-browser and buildwrapper failed.
[root#localhost ghc-mod]# cabal install scion-browser
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: scion-browser-0.3.0
[root#localhost ghc-mod]# cabal install buildwrapper
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: buildwrapper-0.8.0
I briefly went on #haskell IRC but couldn't get an answer but I didn't hang around long in IRC. Then I gave up on EclipseFP and went on merry path with vim. I've used vim before for other languages and I thought I will be fine even though I might not have a debugger. But curiosity took me to install few plugins that can enhance my coding experience in haskell, however one of the plugins require ghc-mod so I thought I'll give cabal install a go again. I ended up with following error.
[root#localhost ghc-mod]# cabal install ghc-mod
Resolving dependencies...
Configuring ghc-mod-0.3.0...
Building ghc-mod-0.3.0...
Preprocessing executable 'ghc-mod' for ghc-mod-0.3.0...
[1 of 6] Compiling Param ( Param.hs, dist/build/ghc-mod/ghc-mod-tmp/Param.o )
[2 of 6] Compiling Lang ( Lang.hs, dist/build/ghc-mod/ghc-mod-tmp/Lang.o )
[3 of 6] Compiling List ( List.hs, dist/build/ghc-mod/ghc-mod-tmp/List.o )
[4 of 6] Compiling Check ( Check.hs, dist/build/ghc-mod/ghc-mod-tmp/Check.o )
[5 of 6] Compiling Browse ( Browse.hs, dist/build/ghc-mod/ghc-mod-tmp/Browse.o )
Browse.hs:41:72:
Not in scope: data constructor `ExplicitForall'
Perhaps you meant `ExplicitForAll' (imported from Language.Haskell.Exts.Extension)
Failed to install ghc-mod-0.3.0
cabal: Error: some packages failed to install:
ghc-mod-0.3.0 failed during the building phase. The exception was:
ExitFailure 1
I tried cloning the project then running cabal install and I end up with following result.
[root#localhost ghc-mod]# cabal install
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: ghc-mod-4.1.0
I'd really like to get to the bottom of this issue. I don't know exactly where cabal is failing so it is really hard to find out what dependency it is complaining about exactly. By the way following are the versions of cabal and ghc.
[root#localhost ghc-mod]# cabal --version
cabal-install version 1.16.0.2
using version 1.16.0 of the Cabal library
[root#localhost ghc-mod]#
[root#localhost ghc-mod]# ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.6.3
Could anyone help me understand the error message from cabal please? I'm relatively new to haskell so apologies if I've missed a trivial point.

Trouble installing hstats library from hackage using cabal

When I try to install the hstats package
$ cabal install hstats
I get the following error:
src/Math/Statistics.hs:1:1:
Ambiguous module name `Prelude':
it was found in multiple packages: base haskell98-2.0.0.2
Failed to install hstats-0.3
cabal: Error: some packages failed to install:
hstats-0.3 failed during the building phase. The exception was:
ExitFailure 1
How can I fix this?
hstats depends on base >= 2.0 and haskell98. The current version of base contains the Prelude module, which was part of haskell98 at the time base was still in version 2.x, but Prelude is now part of the base package.
You need to unpack hstats and fix the error by yourself. Basically, exchange
build-depends: base>=2.0, haskell98
with
build-depends: base>=4.0
in hstats.cabal:
$ cabal unpack hstats
$ cd hstats-0.3
$ vim hstats.cabal
$ cabal install .

cabal install hangs installing yesod-platform

The cabal install of yesod-platform hangs downloading xss-sanitize. NetHogs shows no network activity related to this download.
$ cabal install yesod-platform
Resolving dependencies...
Downloading xss-sanitize-0.3.4...
Other packages download and install without delay.
I'm on Fedora 18. The haskell-platform and cabal-install are up-to-date from the repos.
$ cabal --version
cabal-install version 0.14.0
using version 1.14.0 of the Cabal library
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.4.1
Edit
I left it run overnight it seemed to give up on xss-sanitizer, and continued installing the other dependencies. Here is the tail.
...
Configuring yesod-test-1.2.1...
Building yesod-test-1.2.1...
Preprocessing library yesod-test-1.2.1...
[1 of 3] Compiling Yesod.Test.CssQuery ( Yesod/Test/CssQuery.hs, dist/build/Yesod/Test/CssQuery.o )
[2 of 3] Compiling Yesod.Test.TransversingCSS ( Yesod/Test/TransversingCSS.hs, dist/build/Yesod/Test/TransversingCSS.o )
[3 of 3] Compiling Yesod.Test ( Yesod/Test.hs, dist/build/Yesod/Test.o )
Yesod/Test.hs:113:1:
Warning: In the use of `runFakeHandler'
(imported from Yesod.Core, but defined in yesod-core-1.2.4.2:Yesod.Core.Internal.Run):
"Usually you should *not* use runFakeHandler unless you really understand how it works and why you need it."
Registering yesod-test-1.2.1...
Installing library in /home/smithd/.cabal/lib/yesod-test-1.2.1/ghc-7.4.1
cabal: Error: some packages failed to install:
xss-sanitize-0.3.4 failed while downloading the package. The exception was:
<socket: 4>: hGetBufSome: timeout (Connection timed out)
yesod-1.2.2.1 depends on xss-sanitize-0.3.4 which failed to install.
yesod-auth-1.2.2.1 depends on xss-sanitize-0.3.4 which failed to install.
yesod-form-1.3.2.1 depends on xss-sanitize-0.3.4 which failed to install.
yesod-platform-1.2.4.2 depends on xss-sanitize-0.3.4 which failed to install.
[smithd#lin2900 ~]$ cabal install yesod-platform
My companies internet filter was blocking the haskell-xss-sanitize package as a possible XSS threat. Specifically the test modules. Have your admin white-list hackage if possible.

Resources