Search code examples
cabalhaskell-stackcabal-install

installing hackage package with stack (not in LTS or nightly)


I'm getting started with stack, and I'm not entirely sure how to pull in a package that appears in hackage but not in the curated builds.

In particular, I'd like to pull in thrift-0.10.0. It seems I can't specify it in my project.cabal file, nor does the extra-deps section work since there is no resolver that contains this package.

When I run stack install thrift-0.10.0, I receive the following error:

While constructing the build plan, the following exceptions were encountered:
In the dependencies for thrift-0.10.0:
    vector-0.11.0.0 must match ==0.10.12.2 (latest applicable is 0.10.12.2)

I'm not really sure (a) what stack install does, and (b) how to resolve the build plan since the thrift package specifies an equality (==) on the vector-0.10.12.2 package. If I try and include the relevant vector == 0.10.12.2 in my package.cabal, that also fails. Do I need to specify an earlier resolver?

I realize I have much to learn about this build tool, but in this case, my primary question, for which no documentation seems readily available is:

how do I include a hackage package in my stack build?


Solution

  • nor does the extra-deps section work since there is no resolver that contains this package.

    extra-deps can contain any hackage package.

    (a) what stack install does

    It just does a build of the package + copying of executables to .local/bin

    Install shouldn't be used for dependencies, instead it should be used for your local project / applications from hackage (packages with executables). There is no benefit to installing the dependencies of your project, instead they should be specified in stack.yaml

    (b) how to resolve the build plan since the thrift package specifies an equality (==) on the vector-0.10.12.2 package.

    It seems really ugly for the thrift package to have an (==) constraint like that. To get around it either do "allow-newer: true" in your stack.yaml (causes constraints to get ignored). Or, probably better, add `vector-0.10.12.2" to your extra-deps.

    for which no documentation seems readily available is:

    how do I include a hackage package in my stack build?

    See this section of docs: https://docs.haskellstack.org/en/stable/GUIDE/#external-dependencies