Trouble installing hstats library from hackage using cabal - haskell

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 .

Related

Cabal install http-conduit-browser

It's possible this is such a struggle because I'm on Windows... My latest attempt to get out of Cabal Hell, using the Git Bash:
$ rm -R ~/AppData/Roaming/ghc ~/AppData/Roaming/cabal
$ cabal update
$ cabal install cabal-install
$ cabal install http-conduit-browser
Which results in:
Failed to install http-conduit-1.9.6
Last 10 lines of the build log ( C:\Users\T\AppData\Roaming\cabal\logs\http-conduit-1.9.6.log ):
so you can specify the instance context yourself
When deriving the instance for (Read Cookie)
Network\HTTP\Conduit\Types.hs:239:19:
No instance for (Show UTCTime)
arising from the third field of `Cookie' (type `UTCTime')
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
When deriving the instance for (Show Cookie)
cabal.exe: Error: some packages failed to install:
http-conduit-1.9.6 failed during the building phase. The exception was:
ExitFailure 1
http-conduit-browser-1.9.0.2 depends on http-conduit-1.9.6 which failed to
install.
Attempting to just install http-conduit works fine, but I can't seem to get http-conduit-browser installed at all. If this can't work, are there any other libraries out there? I've also tried shpider but it won't work because of the curl library.
The github page for http-conduit-browser (link) recommends that you use wreq (link) instead.
If you want to use http-conduit-browser here's the trick to getting http-conduit-1.9.6 to build:
cabal get http-conduit-1.9.6
cd http-conduit-1.9.6
modify Network/HTTP/Conduit/Types.hs according to this SO answer: (link) [replace import Data.Time.Clock with import Data.Time]
cabal install
Now you should be able to build http-conduit-browser.

cabal dependency resolution fail for 'lens'

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!

Haskell cabal-install errors

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.
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
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.

Cabal fails to install Idris language on OSX Lion

I'm trying to install the Idris language in an OSX Lion using the installation guide provided on the official tutorial. I have alraedy installed GMP. This is the error I get:
$ cabal install idris
Resolving dependencies...
Configuring libffi-0.1...
cabal: The pkg-config package libffi is required but it could not be found.
[1 of 1] Compiling Main ( /var/folders/f0/dlx6tl5x18z4k4_vq0fkqtb80000gn/T/llvm-general-3.3.5.0-61662/llvm-general-3.3.5.0/Setup.hs, /var/folders/f0/dlx6tl5x18z4k4_vq0fkqtb80000gn/T/llvm-general-3.3.5.0-61662/llvm-general-3.3.5.0/dist/setup/Main.o )
Linking /var/folders/f0/dlx6tl5x18z4k4_vq0fkqtb80000gn/T/llvm-general-3.3.5.0-61662/llvm-general-3.3.5.0/dist/setup/setup ...
setup: The program llvm-config version ==3.3.* is required but it could not be
found.
cabal: Error: some packages failed to install:
idris-0.9.9 depends on llvm-general-3.3.5.0 which failed to install.
libffi-0.1 failed during the configure step. The exception was:
ExitFailure 1
llvm-general-3.3.5.0 failed during the configure step. The exception was:
ExitFailure 1
Trying to install Idris without LLVM produces this error:
$ cabal install idris -f-LLVM
Resolving dependencies...
Configuring libffi-0.1...
cabal: The pkg-config package libffi is required but it could not be found.
cabal: Error: some packages failed to install:
idris-0.9.9 depends on libffi-0.1 which failed to install.
libffi-0.1 failed during the configure step. The exception was:
ExitFailure 1
I was having this same problem on OSX Mavericks. To get Idris to compile, I used homebrew to install gmp, then I had to do 'export PKG_CONFIG_PATH=/usr/local/Cellar/libffi/3.0.13/lib/pkgconfig', and then 'cabal install idris -f-LLVM'. I got the tip to export the PKG_CONFIG_PATH variable from this site:
https://groups.google.com/d/msg/idris-lang/gxcdvRIA2OI/NqKSd4zHkI4J
Mavericks already had libffi installed, and I didn't want to install a second copy from source, which is what the PKG_CONFIG_PATH trick helped me avoid. Do 'brew info libffi' to find the correct path to export. Hopefully someone will create a homebrew formula for Idris soon...
The first error indicates you should install the LLVM development packages of your distribution (not through cabal) and the second indicates you should install the development package for the GCC libffi library. What Linux distribution are you using? Or are you on Windows/Mac?

cabal error: Could not find module `GHC.TypeLits'. How do I fix this?

I get the following when trying to install Hlearn:
$ cabal install HLearn-distributions --ghc-options=-XConstraintKinds
Resolving dependencies...
Configuring HLearn-distributions-0.1.0.1...
Building HLearn-distributions-0.1.0.1...
Preprocessing library HLearn-distributions-0.1.0.1...
src\HLearn\Models\Distributions\Moments.hs:13:14:
Warning: -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
src\HLearn\Models\Distributions\Moments.hs:24:8:
Could not find module `GHC.TypeLits'
Perhaps you meant GHC.Types (needs flag -package ghc-prim)
Use -v to see a list of the files searched for.
cabal.exe: Error: some packages failed to install:
HLearn-distributions-0.1.0.1 failed during the building phase. The exception
was:
ExitFailure 1
I've tried installing the package using cabal (cabal install ghc-prim) but there's no such package. Also tried
$ cabal install HLearn-distributions --ghc-options=-XConstraintKinds -f-package ghc-prim
cabal.exe: There is no package named 'ghc-prim'.
You may need to run 'cabal update' to get the latest list of available
packages.
Any suggestions?
The module GHC.TypeLits is only available from base-4.6 on, with ghc-7.6.1.
I don't see any guards around the import, so the stated constraints on base in the build-depends are wrong in the versions 0.1.0.0 and 0.1.0.1.
If you want to install that package, you have to upgrade to ghc-7.6 or install a version < 0.1,
$ cabal-install "HLearn-distributions < 0.1"

Resources