Reputation: 24774
Trying to run
stack install git-mediate
(per git-mediate
's instructions)
I get an error message regarding dependent package versions:
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for git-mediate-1.0.8:
Diff-0.3.4 from stack configuration does not match >=0.4 (latest matching version is 0.4.0)
needed since git-mediate is a build target.
Some different approaches to resolving this:
* Set 'allow-newer: true' in /Users/yairchu/.stack/config.yaml to ignore all version constraints and build anyway.
* Recommended action: try adding the following to your extra-deps in /Users/yairchu/.stack/global-project/stack.yaml:
- Diff-0.4.0@sha256:b5cfbeed498f555a18774ffd549bbeff7a24bdfe5984154dcfc9f4328a3c2847,1275
Plan construction failed.
It's odd that the stack configuration has Diff-0.3.4
, as currently both LTS and nightly stackage snapshots currently contain Diff-0.4.0
(lts-16.8
and nightly-2020-10-13
).
What is this stack configuration thing and why is it pinned to old versions of libraries?
Upvotes: 1
Views: 529
Reputation: 50929
stack install
is an alias for stack build --copy-bins
, so it's really just stack build
plus the additional step of copying the built executables to ~/.local/bin
.
So, the real question is "how does stack build
decide what resolver to use?" Well, if you provide it on the command line, it uses that one, as in:
stack install --resolver lts-16.18 git-mediate
If you don't give an explicit resolver, the default depends on where the build command is run. If you run it inside a stack project, it'll default to the resolver specified in the project's stack.yaml
file. For example:
stack new --resolver lts-16.0 exampleproject # create project with lts-16.0 resolver
cd exampleproject
stack build git-mediate # this will build git-mediate using lts-16.0
If you build it outside of any project, then it uses the global project setting, which will be whatever resolver
is set in ~/.stack/global-project/stack.yaml
, as mentioned in the comments / other answer.
Note that the stack install
alias will always copy the executable into the "global" ~/.local/bin
, regardless of where it was built. So, if you run stack install git-mediate
in the exampleproject
directory, as above, you'll get the version built with lts-16.0
as the globally installed version.
Soooo... be careful where you run stack install
!
Note that, with respect to git-mediate
specfically, there was recently a buggy version published to Stackage, as documented here. The error message is slightly different than the one you got, but the underlying problem might have been the same. So, it's possible that just running stack update
without having to modify the resolver setting would work to fix your build problem, if you haven't already fixed it.
Upvotes: 1
Reputation: 24774
stack
is implicitly using it's "global project" defined in ~/.stack/global-project/stack.yaml
. To control the stackage snapshot being used this file can be edited (or just deleted to use the latest LTS)
Upvotes: 1