I am trying to build a package to deploy using propellor, and have not even been able to get it to configure due to dependency issues.
Here is the error message that I get:
$ cabal new-configure
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: prod-0.0.1 (user goal)
trying: base-4.9.1.0/installed-4.9... (dependency of prod-0.0.1)
trying: transformers-0.5.2.0/installed-0.5... (dependency of propellor-2.17.0)
next goal: MonadCatchIO-transformers (dependency of prod-0.0.1)
rejecting: MonadCatchIO-transformers-0.3.1.3 (conflict:
base==4.9.1.0/installed-4.9..., MonadCatchIO-transformers => base<4.9)
rejecting: MonadCatchIO-transformers-0.3.1.2,
MonadCatchIO-transformers-0.3.1.1, MonadCatchIO-transformers-0.3.1.0
(conflict: base==4.9.1.0/installed-4.9..., MonadCatchIO-transformers =>
base<4.8)
rejecting: MonadCatchIO-transformers-0.3.0.0,
MonadCatchIO-transformers-0.2.2.3, MonadCatchIO-transformers-0.2.2.2,
MonadCatchIO-transformers-0.2.2.1, MonadCatchIO-transformers-0.2.2.0,
MonadCatchIO-transformers-0.2.1.0, MonadCatchIO-transformers-0.2.0.0
(conflict: base==4.9.1.0/installed-4.9..., MonadCatchIO-transformers =>
base<4.7)
rejecting: MonadCatchIO-transformers-0.1.0.1 (conflict:
transformers==0.5.2.0/installed-0.5..., MonadCatchIO-transformers =>
transformers==0.1.*)
rejecting: MonadCatchIO-transformers-0.1.0.0,
MonadCatchIO-transformers-0.0.2.0, MonadCatchIO-transformers-0.0.1.0
(conflict: transformers==0.5.2.0/installed-0.5..., MonadCatchIO-transformers
=> transformers<0.2)
Dependency tree exhaustively searched.
It seems that the package 'MonadCatchIO-transformers' package requires an older version of 'base', and a much older version of transformers.
I have tried following the advice of this post (editing the configuration of MonadCatchIO-transformers and then installing) to override these requirements, but somehow get the same error message.
I have also tried many other things including this with and without sandboxes, and reinstalling my entire ghc, etc. Is there any way out of this cabal hell?
The first thing you should do when facing unsatisfiable dependencies for Hackage packages is checking the package documentation at Hackage to have a broader picture of the problem. In this case, the documentation reveals that MonadCatchIO-transformers was deprecated in favour of the exceptions package, that provides a similar interface (which explains why MonadCatchIO-transforemrs wasn't updated for base 4.9). That being so, you have basically three approaches for getting your package to build:
1. Switch your code to exceptions
Since MonadCatchIO-transformers appears to be a dependency that you are directly using in your code (as opposed to a transitive dependency), the recommended long-term solution is updating your code to use exceptions rather than MonadCatchIO-transformers.
2. Use GHC 7.10 for this project
If you can't, or don't want to, switch to exceptions right now, an alternative is setting up a parallel GHC 7.10.x installation, so that you can use base 4.8. Suggestions of ways to conveniently using cabal-install with multiple versions of GHC are presented in Using cabal with multiple GHC versions (through cabal settings -- be sure to also read the more recent answers further down the page) and in this blog post by Edsko de Vries (by managing your bash environment). Another possibility is using Stack (rather than cabal-install) to build this specific project and switching to a resolver that provides base 4.8 and MonadCatchIO-transformers (such as the LTS 6.30 Stackage snapshot), as Stack can install and manage alternative GHC versions for projects that require it (cf. the stack setup command). Stack doesn't interfere with your usual cabal-install environment or with your system-wide GHC installation; that being so, if you switch this project to Stack you can remain using cabal-install everywhere else just fine.
3. Adjust the upper bounds of MonadCatchIO-transformers
There is also approach of installing a custom version of MonadCatchIO-transformers with adjusted upper bounds of base and transformers. While that may be the quickest way to get it up and running, in this case it is also the least sustainable one, considering that MonadCatchIO-transformers has been deprecated for several years already. As for why that didn't work for you...
I have tried following the advice of this post (editing the configuration of MonadCatchIO-transformers and then installing) to override these requirements, but somehow get the same error message.
... the fact you got literally the same error message suggests that cabal-install didn't pick your custom MonadCatchIO-transformers version. Have you changed the version of MonadCatchIO-transformers, both in the .cabal file you changed (as suggested in the Q&A you linked to) and in the .cabal file of your project?
Related
I am a total Haskell beginner, and am going through the Hudak book Haskell School of Expression. I am working on the graphics chapter, and have found an updated version of the book's graphics library: https://github.com/noughtmare/haskell-school-of-expression. However, when I run cabal v1-build, I get
Resolving dependencies...
Warning: solver failed to find a solution:
Could not resolve dependencies:
[__0] trying: SOE-0.1.0.0 (user goal)
[__1] next goal: base (dependency of SOE)
[__1] rejecting: base-4.12.0.0/installed-4.12.0.0 (conflict: SOE => base>=4.13
&& <4.15)
[__1] fail (backjumping, conflict set: SOE, base)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: SOE, base
Trying configure anyway.
Configuring SOE-0.1.0.0...
cabal-3.6.2.0.exe: Encountered missing or private dependencies:
GLFW-b, base >=4.13 && <4.15, freetype2, old-time
I do know that base is just the Haskell Prelude, which I know I have, so I have no idea what to do here. Thanks!
The specific error you're seeing occurs because the version of GHC you have installed is not compatible with that package.
The reason is that the base package version is locked to a specific GHC version, so you cannot use newer versions of base with older versions of GHC. See this wiki page for a list of the corresponding GHC version for each base version.
You could upgrade to a newer GHC version, such as 8.10.7.
An alternative is to run cabal with --allow-older=base.
And now I have actually updated the package to change the lower bound from 4.13 to 4.12, so it should compile fine if you pull the latest changes.
Also, I would recommend using the default v2-build, but that is not immediately related to the error you're seeing.
I'm trying to build my package using a sandbox. Without it, it compiles and works like a charm. Once I introduce a sandbox though cabal says it can't resolve dependencies. To my eyes these conflicts do not look like conflicts though.
The project structure is as follows:
application (depends on library-base, library-impl1 and library-impl2)
library
├ library-base
├ library-impl1 (depends on library-base)
└ library-impl2 (depends on library-base)
These are the commands I ran in that order
rm -rf ~/.cabal
rm -rf ~/.ghc
cabal update
rm -f cabal.sandbox.config
rm -rf .cabal-sandbox
cabal sandbox init
cabal sandbox add-source $LIB_HOME/library-base
cabal sandbox add-source $LIB_HOME/library-impl1
cabal sandbox add-source $LIB_HOME/library-impl2
cabal install --only-dependencies --force-reinstalls && cabal build
cabal install --only-dependencies --force-reinstalls produces the following output:
Resolving dependencies...
cabal: Could not resolve dependencies:
next goal: lens (dependency of library-base-0.1.0.0)
rejecting: lens-4.15.4/installed-I5C... (conflict: bifunctors==5.4.2, lens =>
bifunctors==5.4.2/installed-Hs7...)
trying: lens-4.15.4
trying: unordered-containers-0.2.8.0/installed-1tq... (dependency of
lens-4.15.4)
next goal: text (dependency of lens-4.15.4)
rejecting: text-1.2.2.2/installed-3EN... (conflict: binary==0.8.5.1, text =>
binary==0.8.3.0/installed-0.8...)
trying: text-1.2.2.2
next goal: hashable (dependency of lens-4.15.4)
rejecting: hashable-1.2.6.1/installed-2nP... (conflict: text==1.2.2.2,
hashable => text==1.2.2.2/installed-3EN...)
rejecting: hashable-1.2.6.1, hashable-1.2.6.0, hashable-1.2.5.0,
hashable-1.2.4.0, hashable-1.2.3.3, hashable-1.2.3.2, hashable-1.2.3.1,
hashable-1.2.3.0, hashable-1.2.2.0, hashable-1.2.1.0, hashable-1.2.0.10,
hashable-1.2.0.9, hashable-1.2.0.8, hashable-1.2.0.7, hashable-1.2.0.6,
hashable-1.2.0.5, hashable-1.2.0.4, hashable-1.2.0.3, hashable-1.2.0.2,
hashable-1.2.0.1, hashable-1.2.0.0, hashable-1.1.2.5, hashable-1.1.2.4,
hashable-1.1.2.3, hashable-1.1.2.2, hashable-1.1.2.1, hashable-1.1.2.0,
hashable-1.1.1.0, hashable-1.1.0.0, hashable-1.0.1.1, hashable-1.0.1.0,
hashable-1.0.0 (conflict: unordered-containers =>
hashable==1.2.6.1/installed-2nP...)
Dependency tree exhaustively searched.
Does anyone have an idea what is going on here?
First I will give an explanation of what the error message says. Then I will attempt to make some guesses about why you have the error. Then I will propose some next steps.
The error says:
Maybe version 4.15.4 of lens will work.
Maybe the installed version 0.2.8.0 of unordered-containers will satisfy lens' dependency on unordered-containers.
Maybe the installed version 1.2.2.2 of text will satisfy lens' dependency on text.
Crap. You asked for version 0.8.5.1 of binary, but the installed version of text was built against version 0.8.3.0. I have to rebuild text.
Maybe the installed version 1.2.6.1 version of hashable will satisfy lens' dependency on hashable.
Crap. We're rebuilding text, a dependency of hashable. I have to rebuild hashable.
Double crap. We already committed to using the installed version of unordered-containers, which depends on the installed version of hashable, which prevents us from rebuilding hashable.
(...and I tried a bunch of other stuff that didn't work, too, but I'm not telling you what, nya nya nya)
Normally sandboxes ignore local package databases, so this suggests to me that where it is talking about "installed versions" above it is either picking these up from your global package database or from your existing sandbox. You claim that you have just created this sandbox and run this cabal install command immediately. If this is true (is it? or is this a second run of the tool? why do you have --force-reinstalls?), it cannot be picking the installed versions from your sandbox, and therefore must be picking them up from your global package database. Installing things to the global package database is generally considered a Bad Idea, because it's much more difficult to correctly clear out a cluttered/broken global package database. Take it under future advisement.
Now, to make progress, I would try one of these two things:
The only part of the above error explanation that you have control over is the "You asked for version 0.8.5.1 of binary" part. Consider relaxing your version constraints on binary to accept the already-installed version 0.8.3.0.
You can often get significantly better error messages out of cabal by cutting down on its search space; because it only prints a part of the search space in its error, you sometimes need to guide it to the problematic part of the space so that it will show you the real problem in its error. If you're pretty sure the installed versions of unordered-containers et al are a good match for your library, consider
cabal install --only-dependencies --constraint 'unordered-containers installed' --constraint 'binary installed'
and so on for any other packages it mentions trying to rebuild that you don't want it to rebuild. Alternately you can put exact version constraints in the --constraint if you don't want one of the installed versions. Don't include --force-reinstalls, basically ever.
I am totally new to Haskell an cabal and I'm trying to make yesod work.
My cabal version is cabal-install version 1.20.0.3
using version 1.20.0.2 of the Cabal library
This is what happends when I tru to install alex:
$ cabal install alex
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: alex-3.1.4 (user goal)
next goal: QuickCheck (dependency of alex-3.1.4)
rejecting: QuickCheck-2.8.1, 2.8 (global constraint requires ==2.7.6)
trying: QuickCheck-2.7.6
next goal: transformers (dependency of QuickCheck-2.7.6)
rejecting: transformers-0.4.3.0, 0.4.2.0, 0.4.1.0, 0.3.0.0, 0.2.2.1, 0.2.2.0,
0.2.1.0, 0.2.0.0, 0.1.4.0, 0.1.3.0, 0.1.1.0, 0.1.0.1, 0.1.0.0, 0.0.1.0,
0.0.0.0, 0.4.0.0 (global constraint requires installed instance)
Dependency tree exhaustively searched.
Second attempt:
$ cabal install alex happy yesod-bin --allow-newer
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: alex-3.1.4 (user goal)
trying: QuickCheck-2.7.6/installed-1a8... (dependency of alex-3.1.4)
trying: tf-random-0.5/installed-ef3... (dependency of
QuickCheck-2.7.6/installed-1a8...)
next goal: primitive (dependency of tf-random-0.5/installed-ef3...)
rejecting: primitive-0.5.0.1/installed-8e5... (global constraint requires
==0.6)
rejecting: primitive-0.6 (conflict: tf-random =>
primitive==0.5.0.1/installed-8e5...)
rejecting: primitive-0.5.4.0, 0.5.3.0, 0.5.2.1, 0.5.1.0, 0.5.0.1, 0.5, 0.4.1,
0.4.0.1, 0.4, 0.3.1, 0.3, 0.2.1, 0.2, 0.1 (global constraint requires ==0.6)
Dependency tree exhaustively searched.
What do I have to do to install alex?
A related question is this one:
cabal install --- global constraint requires installed instance
The comment by #kosmikus on that question is:
So the Stackage LTS config file contains the constraint transformers
installed, meaning that only an already present version of
transformers can be used. This is reasonable, because GHC ships with a
specific version of transformers. For ghc-7.8, this is
transformers-0.3.0.0. For some reason, this installed version is not
considered by cabal-install. Your partial log doesn't contain
sufficient info to see why.
How can I fix my Stackage LTS config file? Where is it on Ubuntu?
Try this cabal install alex --allow-newer
The reason of the problem was that my GHC was too old. I downloaded a newer version and solved the problem.
Failed (and wrong) attempt
You should have a cabal.config file in your current directory. Open it with any text editor and serach for the transformers installed string.
Once you have found it, replace it with transformers ==0.4.3.0 or any other version you like.
It is a bad solution, because, as dfeurer writes:
transformers sits very far down in the package dependency structure. I
believe it depends only on base; I imagine a large majority of
packages on Hackage depend, directly or indirectly, on it. If you
upgrade transformers, practically every dependency in the system will
go screwy, which is the opposite of what you're going for if you're
using Stackage.
Clean solution by Sibi
Use the stackage packages as it is. If you have some global package causing problem, then remove them and use stackage exclusively. Also using sandbox for each project is a good idea.
Different programming languages use different packaging systems.
In their varied approach, Java's Maven looks like the best bet for me since it maintains different version of jar files in seperately versioned folders and hence, there is no way one will end up in conflicting versions of a library.
Next comes python. Python's pip puts its packages into /usr/local/lib/python/dist-packages/site-packages. When there is a version conflict, one can use its virtualenv and live with it.
Nodejs supports installing packages both in local folders and global folders. Till date for me, i never had a dependency conflict in the global libraries.
Then I got fascinated by the haskell's style and started using cabal. First, i was installing my libraries inside /home/user1/.cabal. Then when the package system broke, one friend suggested me to remove two folders - /home/user1/.cabal && /home/user1/.ghc. Now, my first confusion arose, why does cabal's library files sit in two folders .cabal && .ghc. I cleaned the library folders, ~/.ghc and ~/.cabal and did cabal install from a package source for cabal-db-0.1.12. Now, there was a new error and i was surprised, because i had sanitized all local repositories. The error was,
Configuring Cabal-1.22.2.0...
Building Cabal-1.22.2.0...
Installed Cabal-1.22.2.0
cabal: Error: some packages failed to install:
ansi-terminal-0.6.2.1 failed during the configure step. The exception was:
user error (The package 'ansi-terminal' requires Cabal library version -any &&
>=1.6 but no suitable version is installed.)
Then I tried the safest bet - sandbox for cabal-db. It worked. Then i repeated sandboxing for another pacakge, ghc-pkg-autofix. I did,
cd ghc-pkg-autofix-0.2.0.1
cabal sandbox init
cabal install
And for sandbox where there are absolutely no external dependencies, there are errors again,
cabal: Could not resolve dependencies:
trying: ghc-pkg-autofix-0.2.0.1 (user goal)
trying: Cabal-1.22.2.0 (dependency of ghc-pkg-autofix-0.2.0.1)
next goal: process (dependency of ghc-pkg-autofix-0.2.0.1)
rejecting: process-1.2.0.0/installed-06c..., 1.2.3.0, 1.2.2.0, 1.2.1.0,
1.2.0.0, 1.1.0.2, 1.1.0.1, 1.1.0.0 (conflict: ghc-pkg-autofix => process>=1.0
&& <1.1)
rejecting: process-1.0.1.5, 1.0.1.4, 1.0.1.3, 1.0.1.2, 1.0.1.1, 1.0.0.0
(conflict: Cabal => process>=1.1.0.1 && <1.3)
Dependency tree exhaustively searched.
Note: when using a sandbox, all packages are required to have consistent
dependencies. Try reinstalling/unregistering the offending packages or
recreating the sandbox.
Am i doing something wrong (or) this kind of dependency conflicts are quite common in cabal? I see, managing dependencies in other languages are a lot simpler.
Note: I use cabal-install version 1.22.0.0 && The Glorious Glasgow Haskell Compilation System, version 7.8.4
"And for sandbox where there are absolutely no external dependencies" this is not true. A sandbox still has dependencies on the global package database. Things like Cabal, GHC, process are typically installed in the global package database. Here you want to install ghc-pkg-autofix which requires process 1.0, but you have a more recent version of process already installed. Are you sure you need ghc-pkg-autofix, it seems to be quite old.
I'm having a trouble on installing Polyparse library (Haskell library)
And i do not know how to solve it ....
May someone helps me,please ?
This is the error output :
D-MacBook-Pro:polyparse-1.9 d$ cabal install polyparse.cabal
Resolving dependencies...
Configuring polyparse-1.9...
Failed to install polyparse-1.9
Last 10 lines of the build log ( /Users/d/.cabal/logs/polyparse-1.9.log ):
cabal: /Users/d/.cabal/logs/polyparse-1.9.log: does not exist
The problem now ...
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: bpsat-0.1.0 (user goal)
trying: smt-lib-0.0.3/installed-d94... (dependency of bpsat-0.1.0)
next goal: polyparse (dependency of smt-lib-0.0.3/installed-d94...)
rejecting: polyparse-1.9/installed-42c... (conflict: polyparse =>
text==1.1.1.2/installed-cb1..., bpsat => text==0.11.*)
rejecting: polyparse-1.9, 1.8, 1.7, 1.6, 1.5, 1.4.1, 1.4, 1.3, 1.2, 1.1, 1.0
(conflict: smt-lib => polyparse==1.9/installed-42c...)
Dependency tree exhaustively searched.
I just tried to install polyparse on my Ubuntu machine, and it worked....
Here is how I usually fix installation problems.
$ cabal update
$ cabal unpack polyparse
$ cd polyparse-*
$ cabal configure
Now look for errors.... Dependency errors usually appear at this point. They come in two forms- Either 1). for some reason another cabal package is missing, and you can usually install it by doing the appropriate cabal install <packageName> (yes, cabal was supposed to do this for you, but I find it sometimes doesn't), or 2). A system c-library is missing, and you will have install that. Either way, the message should make it clear. If it doesn't, append the message to your question and we can help.
$ cabal build
Again, look for errors. Build errors often appear here, and usually indicate a bug in the package. Since the install just worked for me, this is less likely, but I've seen stuff that installs on one OS and breaks on another. Again, you can put the message here and we can help.
$ cabal install
If this works, the package should be installed.
update
It looks like the dependency smt-lib isn't installing.... Try to repeat the steps above on that lib, and repost the results.
Update 2-
The new error message looks to be telling me there is a conflict in the Text lib, bpsat needs one version and polyparse needs another. I am not sure why this is happening, as I mentioned, for me things worked. Sometimes things in ~/.cabal get messed up, and you might want to try to delete (well, actually, move it in case you decide you need it) everything in .cabal except ~/.cabal/bin/. Then try again. You will probably have to reinstall other libs, but this might solve the problem.