Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stack not resolving dependencies properly

I'm trying to set up Hakyll on a fresh Ubuntu 16.04 instance, but I can't seem to get the Stack-based setup instructions right.

Starting out with stack install hakyll, I get:

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

In the dependencies for hakyll-4.9.3.0:
    http-conduit-2.1.11 must match >=2.2 && <2.3 (latest applicable is 2.2.3)

Plan construction failed.

I got a similar error when tying to stack-install http-conduit-2.1.11, this time with:

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

In the dependencies for http-conduit-2.2.3:
    http-client-0.4.31.2 must match >=0.5 && <0.6 (latest applicable is 0.5.5)
    http-client-tls-0.2.4.1 must match >=0.3 && <0.4 (latest applicable is 0.3.3.1)

Plan construction failed.

After resolving dependencies for this (also using Stack), I tried once again to stack install http-conduit-2.1.11, but I once again got the same dependency error.

The packages http-client-0.4.31.2 and http-client-tls-0.2.4.1 appear in my ~/.stack/precompiled/x86_64-linux/ghc-8.0.1/1.24.0.0/, which isn't explicitly in my $PATH, however that feels like an extremely hacky solution, and I haven't found any documentation recommending this approach.

How can I correctly install Hakyll on my machine?

like image 237
Jules Avatar asked Jan 21 '17 06:01

Jules


2 Answers

Dependency management with stack is meant to be reproducible and declarative, that means that a stack project will only compile once all dependencies are recorded in the .cabal file(s) of the project and once the stack.yaml of the project defines versions for these dependencies either in the resolver or the extra-deps section.

Your confusion seems to stem from a misunderstanding of what stack install does. The command line help has this to say about it:

  build                    Build the package(s) in this directory/configuration
  install                  Shortcut for 'build --copy-bins'
...
  --[no-]copy-bins         Enable/disable copying binaries to the local-bin-path
                           (see 'stack path')

stack install does not save any dependencies.

So the proper way of making hakyll available as a dependency to your code is:

  • Create a proper stack project with stack init if you already have a Cabal package, or stack new if you don't.

  • Add hakyll to the library or executable build-depends in your .cabal file.

  • Attempt to stack build and follow the instructions in any error messages until all issues are resolved.

like image 112
sjakobi Avatar answered Sep 21 '22 18:09

sjakobi


A simpler solution than @sjakobi's in this case was to specify a resolver as a command line option when starting a new Stack project:

stack install hakyll --resolver=5.11 --install-ghc
like image 32
Jules Avatar answered Sep 17 '22 18:09

Jules