Deciphering a Stack dependency resolution error message

Hi, I’m trying to include large-anon in my stack project, just to putz around with it.

When I add large-anon to my executable’s dependencies, like so:

executables:
  hello-exe:
    main:                Main.hs
    source-dirs:         app
    ghc-options:
    - -threaded
    - -rtsopts
    - -with-rtsopts=-N
    dependencies:
    - hello
    - bytestring
    - aeson
    - large-anon

I get the following error:

While constructing the build plan, Stack encountered the following errors:

In the dependencies for hello-0.1.0.0:
    large-anon needed, but the Stack configuration has no specified version (latest matching version is 0.3.0)
needed since hello is a build target.

Now, I guess it found something related to large-anon out on the internet, because it found a version number of 0.3.0, which appears to be the current version as per large-anon: Scalable anonymous records.

I’m not clear on what the error wants me to do: do I need to specify a particular version? If so, where do I do that? If not, what does the error mean?

Thanks for your time!

large-anon isn’t going to be in a stack snapshot so you need to specify the specific version - which it is then not going to find, but will give you a line to add to your extra-deps section in your stack.yaml file.

EDIT:

Here are the steps I took:

  1. Added large-anon to package.yaml
  2. Pinned it to 0.3.0 with - large-anon-0.3.0 in the extra-deps section of stack.yaml
  3. Stack complained about a number of other missing dependencies (again because they are not in the stack snapshot), so in stack.yaml I added the following:
extra-deps:
- large-anon-0.3.0
- ghc-tcplugin-api-0.10.0.0
- large-generics-0.2.1
- primitive-0.7.4.0@sha256:c2f0ed97b3dce97f2f43b239c3be8b136e4368f1eb7b61322ee9ac98f604622b,2982
- typelet-0.1.3

After this the project compiled.

Great! It compiles now. Many thanks. Now to do something with it, ha ha.

No problem! Good luck I’ve never used it myself but don’t forget you probably need to enable the plugin:

{-# OPTIONS_GHC -fplugin=Data.Record.Anon.Plugin #-}

... the Stack configuration ... is a bit terse in that error message. It means ... the set of package versions that Stack is configured to use .... I’ll look into whether that message could be improved, without becoming too wordy.

The tutorial-style part of Stack’s online documentation here aims to walk through this distinction between (a) dependency packages specified in a package’s Cabal file and (b) the snapshot (the curated set of package versions, extended/amended by extra-deps or trimmed with drop-packages) specified in Stack’s project-level configuration file (stack.yaml).

2 Likes

How about an alternative message like the following?

In the dependencies for hello-0.1.0.0:
    large-anon needed, but no version is in the specified snapshot
    or extra-deps (latest matching version is 0.3.0)
needed since hello is a build target.

‘Snapshot’ and ‘extra-deps’ are explained in Stack’s online glossary.

5 Likes

That looks nice. More context in error messages is always appreciated.

Indeed, this would be very helpful for those who don’t have the muscle memory on how to fix this type of error (out-of-snapshot dependencies).

The master branch version of Stack (if you are not using GHCup to manage Stack: stack upgrade --source-only --git) now has a more descriptive approach to this message. Rather than repeating the description in each item, I’ve added it to the introduction, when it is relevant.

3 Likes