5

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?

sjakobi
  • 3,546
  • 1
  • 25
  • 43
Jules
  • 14,200
  • 13
  • 56
  • 101
  • 1
    I understand now that the the purpose of `stack install hakyll` is to get the `hakyll-init` binary. The command failed because `hakyll-4.9.3.0` isn't compatible with the resolver set in your stack.yaml (probably `~/.stack/global-project/stack.yaml`). `hakyll-4.9.3.0` is included in [nightly-2017-01-17](https://www.stackage.org/nightly-2017-01-17) though, so you can `stack --resolver nightly-2017-01-17 install hakyll`. The rest of [the instructions](https://jaspervdj.be/hakyll/tutorials/01-installation.html) should work roughly as written. – sjakobi Jan 21 '17 at 16:58
  • BTW there's [a proposal for a `--solver` flag](https://github.com/commercialhaskell/stack/issues/2656) that should make installing executables with stack much easier. – sjakobi Jan 22 '17 at 21:17

2 Answers2

3

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.

sjakobi
  • 3,546
  • 1
  • 25
  • 43
  • You can install packages with `stack install` though, it just doesn't make the installed packages available to the project. – Cubic Jan 21 '17 at 14:52
  • @Cubic That depends on what you mean by "install packages". How do you understand it? – sjakobi Jan 21 '17 at 15:30
  • 2
    I can `stack install `, that package will be downloaded, built, I can execute any binaries that are part of the package with `stack exec`... if there's another way to interpret "install packages" I'm not aware of it. – Cubic Jan 21 '17 at 15:42
2

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
Jules
  • 14,200
  • 13
  • 56
  • 101