Reputation: 763
Being advertised as a breakthrough in Haskell tooling, I tried switching from Cabal to Stack. However, I still have a problem getting projects to run with stack that run with cabal. I believe the issue is that there are global constraints set by the resolver (e.g. long term support packages from stackage) that don't comply with local package dependencies.
For a concrete example, I used the snap framework (http://snapframework.com/) in version 0.14.0.6. After creating a full snap project with snap init
, I tried to instantiate a stack build plan from the cabal file with stack init
. However, there was no build plan found by stack that satisfies the constraints.
On the other hand, a cabal install
successfully builds the project.
Is there a mistake in my understanding of stack? How can one resolve this issue?
The complete error log is show below, where the project's name is SnapFull:
Checking against build plan lts-3.7
* Build plan did not match your requirements:
base version 4.8.1.0 found
- SnapFull requires >=4 && <4.4
lens version 4.12.3 found
- SnapFull requires >=3.7.6 && <3.8
snap-loader-dynamic not found
- SnapFull requires ==0.10.*
snap-loader-static not found
- SnapFull requires >=0.9 && <0.10
Checking against build plan lts-2.22
* Build plan did not match your requirements:
base version 4.7.0.2 found
- SnapFull requires >=4 && <4.4
lens version 4.7.0.1 found
- SnapFull requires >=3.7.6 && <3.8
snap-loader-dynamic not found
- SnapFull requires ==0.10.*
snap-loader-static not found
- SnapFull requires >=0.9 && <0.10
Checking against build plan lts-3.8
* Build plan did not match your requirements:
base version 4.8.1.0 found
- SnapFull requires >=4 && <4.4
lens version 4.12.3 found
- SnapFull requires >=3.7.6 && <3.8
snap-loader-dynamic not found
- SnapFull requires ==0.10.*
snap-loader-static not found
- SnapFull requires >=0.9 && <0.10
Checking against build plan nightly-2015-10-09
* Build plan did not match your requirements:
base version 4.8.1.0 found
- SnapFull requires >=4 && <4.4
lens version 4.12.3 found
- SnapFull requires >=3.7.6 && <3.8
snap-loader-dynamic not found
- SnapFull requires ==0.10.*
snap-loader-static not found
- SnapFull requires >=0.9 && <0.10
There was no snapshot found that matched the package bounds in your .cabal files.
Please choose one of the following commands to get started.
stack init --resolver lts-3.7
stack init --resolver lts-2.22
stack init --resolver lts-3.8
stack init --resolver nightly-2015-10-09
You'll then need to add some extra-deps. See:
https://github.com/commercialhaskell/stack/blob/master/doc/yaml_configuration.md#extra-deps
You can also try falling back to a dependency solver with:
stack init --solver
Upvotes: 2
Views: 372
Reputation: 38217
I would suggest giving a non-LTS solver a try:
$ stack init --resolver=ghc-7.10 --force
or
$ stack init --resolver=ghc-7.8 --force
This usually gives working results much more easily than with an lts-*
solver, except you don't get to benefit from the stability of LTS. But since you're coming from Cabal, you didn't have LTS prior to now anyway, so you might as well start out with a regular ghc-7.10
or ghc-7.8
resolver and see if you can move to LTS later on.
P.S. you can also try the nightlies, which is somewhere between lts-*
and ghc-*
I guess, but I haven't tried that myself.
EDIT: after a stack init
command you typically also need to run stack solver --modify-stack-yaml
to populate the extra-deps
section in your stack.yaml
with build dependencies computed from the build-depends
section in your .cabal
file. I think what's happening is that init
only configures the project with a specified solver but doesn't invoke the actual dependency resolution. (I'd appreciate any corrections to this information.)
Upvotes: 3
Reputation: 34378
Your project, SnapFull, asks for too old versions of its dependencies (e.g. base < 4.4
and lens < 3.8
). Those versions are older than what the first Stackage snapshot offers, which explains why stack is unable to find a build plan. In all likelihood, the easiest way to solve your problem is updating the .cabal file of your project to use the latest versions of those dependencies. Additionally, the snap-loader-* packages are not in Stackage, so they need to be added to the extra-deps
field of stack.yaml
. The stack solver --modify-stack-yaml
command can do that for you.
P.S.: This page tells which packages and versions are included in the latest Stackage LTS snapshot. You can also check other snapshots through the "Snapshots" link at the top of the page.
Upvotes: 3