mherzl
mherzl

Reputation: 6200

Why is stack not using the defined extra dependency?

I committed a change to Haskell's opaleye project that I need for a project I am working on. The change is in version 0.6.7003.1, which has not propagated to the nixos repository yet (nixos.org shows its current version to be 0.6.7001.0).

Since this needed dependency differs from the the resolver's LTS version, I have marked the extra dependency in stack.yaml:

packages:
- [email protected]:tomjaguarpaw/haskell-opaleye.git
- commit: cf3296c5ffef58d36dd6b386ae53dff519ee47e9

I have also marked this version in the build-depends of my project.cabal file:

build-depends: opaleye >= 0.6.7003.1 && < 1

When I then attempted to build, I got the following error:

$ stack build

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

In the dependencies for taskmaster-0.1.0.0:
    opaleye must match >=0.6.7003.1 && <1, but the stack configuration has no specified version  (latest matching version is 0.6.7003.1)
needed since taskmaster is a build target.

Some different approaches to resolving this:

  * 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/matthew/backup/taskmaster/taskmaster/stack.yaml:

opaleye-0.6.7003.1@sha256:914ac99c6f7ceea050df843ac31c33be0f6340bc0f05753c8fdfc18074fa9e5b

Plan construction failed.

(I do not understand where this long (>40 char) sha256 hash comes from). I followed the advice and added the following to my stack.yaml.

extra-deps:
- opaleye-0.6.7003.1@sha256:914ac99c6f7ceea050df843ac31c33be0f6340bc0f05753c8fdfc18074fa9e5b

When I run $ stack build to build my project, the compiler attempts to build without showing any dependency errors. However, it strikes a type error that it would not if it were using the version of Opaleye containing my change. And, when I run $ stack ghci and import a relevant opaleye module, my change is not present. It appears that somehow stack is still using an older opaleye version. How can I get stack to use the more recent version of opaleye containing my change? My attempts seem to have exhausted the options mentioned in the haskell-stack documentation.

Upvotes: 0

Views: 232

Answers (2)

David Baynard
David Baynard

Reputation: 235

The hackage option is usually better than the github extra-dep.

The correct syntax for what you initially tried would be

extra-deps:
- git: https://github.com/tomjaguarpaw/haskell-opaleye.git
  commit: cf3296c5ffef58d36dd6b386ae53dff519ee47e9

and the github: tomjaguarpaw/haskell-opaleye version is just a shortcut.

The sha256 hash is the sha256sum of the cabal file corresponding to that version (and revision) of opaleye.

Given that version of opaleye is already on hackage, you should just be able to add the line suggested by stack. You may wish to try a stack clean after you make the change (though it shouldn't be necessary).

If you present more information, I'll update this answer.

Upvotes: 1

mherzl
mherzl

Reputation: 6200

It turned out that stack's extra-deps suggestion was incorrect. I noticed an alternative format under this stack github issue, gave it a try, and it happened to work for me. The working extra-deps format is listed below.

extra-deps:
- github: tomjaguarpaw/haskell-opaleye
  commit: cf3296c5ffef58d36dd6b386ae53dff519ee47e9

Upvotes: 0

Related Questions