What does 'no specified version' mean in my Cabal build?

5.7k views Asked by At

The recent Travis CI build of the development version of my Haskell package reports the error

MissingH must match >=1.3.0.1, but the stack configuration has no specified version (latest matching version is 1.4.0.1)

when building for GHC 8.6.1, even though I have

MissingH >=1.3.0.1 

in my build-depends.

I don't understand this error: it seems contradictory. I have no upper limit on MissingH, so why is it erroring and not using the latest?

1

There are 1 answers

11
Li-yao Xia On

You need to add MissingH to stack.yaml.

extra-deps:
  - 'MissingH-1.4.0.1'
  • Your package's *.cabal file says what versions of dependencies are compatible with your package. It is a loose specification, not all combinations may actually work (because they may have conflicting bounds on transitive dependencies, or there is some unforeseen breakage with a particular version you haven't tested with).

  • In contrast, stack.yaml describes a particular snapshot of packages, pinned to specific versions. This precisely says "my package is known to work with those versions". Of course, it is tedious to maintain the version of every dependency, and for that the Stackage team maintains a "resolver", a curated set of package versions known to work together, that you can use to specify the version of many packages at once, by setting the resolver: field of stack.yaml appropriately. A resolver only lists a subset of packages on Hackage, so when one of your dependencies is not in there, you need to add it to your stack.yaml as an extra-dep.


Update: following the discussion, some more details about configuring travis are necessary.

First, my current preferred solution for CI of Haskell projects is to not bother with stack and use instead https://github.com/haskell-CI/haskell-ci which generates a travis script using cabal-install.

Now for a less radical solution.

Currently the travis script is only varying the --resolver option, but as far as I can tell there is no command line option to add an extra-dep. It seems stack.yaml files are the only way for that. Furthermore, we only want to specify MissingH as an extra-dep for the latest nightlies, because LTS'es already include it.

Thus I suggest the following:

  1. Create a separate stack.yaml for the nightly resolver only, call it something else since you already have one, for example stack-nightly.yaml

    packages:
    - .
    extra-deps:
    - 'MissingH-1.4.0.1'
    
  2. Set an environment variable to point to stack-nightly.yaml when the resolver is a nightly, maybe:

    env:
    ...
    - $RESOLVER=nightly STACK_YAML=stack-nightly.yaml
    # Not sure of the syntax.
    

    Otherwise you can use the --stack-yaml command line option.