简体   繁体   中英

What is the relationship between dependency constraints in “stack configuration”, xxx.cabal, and cabal.config?

I haven't tried solving the issue yet; first I want to understand where the issue comes from:

TextTerra $ stack --nix test

Error: While constructing the build plan, the following exceptions were encountered:

In the dependencies for TextTerra-0.1.0.0:
    easytest-0.2 from stack configuration does not match ==0.2.1  (latest matching version is 0.2.1)
needed since TextTerra is a build target.

Some different approaches to resolving this:

  * Set 'allow-newer: true' to ignore all version constraints and build anyway.

  * Consider trying 'stack solver', which uses the cabal-install solver to attempt to find some working build configuration. This can be convenient when dealing with many complicated constraint
    errors, but results may be unpredictable.

  * Recommended action: try adding the following to your extra-deps in /home/brandon/workspace/TextTerra/stack.yaml:

- easytest-0.2.1

Plan construction failed.

There is now no other reference to easytest, particularly easytest-0.2; the single reference is what I just added:

TextTerra $ rg easytest
TextTerra.cabal
67:      , easytest == 0.2.1

However, there was a reference to easytest-0.2 in cabal.config . I'm not aware of the relevance of this file as a quick search doesn't turn up much and removing the file has no effect on the build (in particular, I get the same error message above).

In...

easytest-0.2 from stack configuration does not match ==0.2.1

... the "stack configuration" means the set of packages specified through the resolver (typically a Stackage snapshot -- you can find lists of packages and versions in a snapshot at the Stackage site ) and the extra-deps in stack.yaml , while the ==0.2.1 constraint is what your .cabal file is asking. The suggestions given by the error message (ignoring .cabal upper bounds with allow-newer , and adding packages to extra-deps ) are appropriate in the cases in which you want, or need, to build with a specific resolver. If that is not the case (say, if you are trying to update an old project to a recent LTS snapshot), you can also change the resolver to something that includes the packages and versions you are looking for (if such a resolver is available).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM