I am currently trying to install helm with stack. I created a simple project with
stack new sandbox
and added helm as a dependency on sandbox.cabal:
library
hs-source-dirs: src
exposed-modules: Lib
build-depends: base >= 4.7 && < 5
, helm
default-language: Haskell2010
After that I run the usual stack build and get the error, indicating that I have to add helm-0.7.1 on my stack.yaml file. I do that and also insert elerea-2.8.0, since it was also a requirement.
This is my stack.yaml:
# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)
resolver: lts-3.12
# Local packages, usually specified by relative directory name
packages:
- '.'
# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)
extra-deps:
- helm-0.7.1
- elerea-2.8.0
# Override default flag values for local packages and extra-deps
flags: {}
# Extra package databases containing global packages
extra-package-dbs: []
# Control whether we use the GHC we find on the path
# system-ghc: true
# Require a specific version of stack, using version ranges
# require-stack-version: -any # Default
# require-stack-version: >= 0.1.4.0
# Override the architecture used by stack, especially useful on Windows
# arch: i386
# arch: x86_64
# Extra directories used by stack for building
# extra-include-dirs: [/path/to/dir]
# extra-lib-dirs: [/path/to/dir]
Running stack build again gives me this error.
While constructing the BuildPlan the following exceptions were encountered:
-- Failure when adding dependencies:
helm: needed (-any), couldn't resolve its dependencies
needed for package: sandbox-0.1.0.0
-- Failure when adding dependencies:
cairo: needed (>0.12 && <0.13), 0.13.1.0 found (latest version available)
mtl: needed (>=2.1 && <2.2), 2.2.1 found (latest version available)
pango: needed (>0.12 && <0.13), 0.13.1.0 found (latest version available)
sdl2: needed (>=1.1 && <1.3), 1.3.1 found (latest is 2.1.0)
time: needed (>=1.4 && <1.5), 1.5.0.1 found (latest version available)
needed for package: helm-0.7.1
What does this error mean? From what I understand it is not finding the correct version.
What it's saying is that the stackage resolver you are trying to use (lts-3.12) is incompatible with helm-0.7.1.
For instance, helm-0.7.1 requires a cairo version between 0.12 and 0.13, but the version of cairo supported in lts-3.12 is 0.13.1. Similarly for the other constraints.
It is possible that the helm might actually work with a later version of cairo. To test that, download the helm source, modify the dependency in its cabal file and include it in your stack project as a local package.
Another suggestion is to see if it builds in a cabal sandbox.
Related
I am trying to use EuterpeaLite (https://github.com/Euterpea/EuterpeaLite), but it is not on Hackage.
I imported it like such import EuterpeaLite as EL and I added it to my cabal file like this:
build-depends:
base >=4.7 && <5
, postgresql-simple
, EuterpeaLite
But when I run stack build or stack ghci, I get this error:
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for engine-0.1.0.0:
EuterpeaLite needed, but the stack configuration has no specified version (no package with that name found, perhaps there
is a typo in a package's build-depends or an omission from the stack.yaml packages list?)
needed since engine is a build target.
Some different approaches to resolving this:
Plan construction failed.
Is there a special process for non-Hackage packages?
I used the following procedure.
Create a new stack project stack new myproject --resolver=14.27. I needed to specify an older resolver, since EuterpeaLite wouldn't build with lts-15.3
In the myproject directory, add the following lines to stack.yaml:
extra-deps:
- git: https://github.com/Euterpea/EuterpeaLite.git
commit: 5fe2d129bd3087dd78c0feaf4d35fc03ffd36215
Also in the myproject directory, I added the following dependency to package.yaml:
dependencies:
- base >= 4.7 && < 5
- EuterpeaLite # <- added this line
Ran stack build in the myproject directory.
As you noted, instead of using package.yaml, you could change your .cabal file.
I am trying to add dependency of gtk2hs-buildtool to my Haskell project but following error while building stack.
In the dependencies for TicTacToe-0.1.0.0:
gtk2hs-buildtools needed, but the stack configuration has no specified version (latest matching
version is 0.13.5.4)
needed since TicTacToe is a build target.
TicTacToe.cabal file:
library
exposed-modules:
TicTacToeEngine
other-modules:
Paths_TicTacToe
hs-source-dirs:
src
build-depends:
base >=4.7 && <5,
gtk2hs-buildtools
default-language: Haskell2010
If you are using stack tool you shouldn't touch the <packagename>.cabal file. stack is in charge to generate it from package.yaml. Despite of the fact that is a common practise to modify the <packagename>.cabal, development workflow will be easier if you don't.
The files you are interested in (and the ones that stack tool uses) are the stack.yaml and package.yaml.
In stack.yaml you should see an entry called resolver: lts-XX.XX. That means that your dependencies version are managed such that they match those in the given lts (a.k.a. snapshot). You can go to https://www.stackage.org/, click on your lts version and search for the gtk2hs-buildtools package to get the right version for your project (example: lts-12.26 uses gtk2hs-buildtools-0.13.4.0). In your package.yaml, in the dependencies section write the entry entry - gtk2hs-buildtools
From lts-13.11 and above gtk2hs-buildtools is not available in stackage, so you need to add it as an extra-dep. in the stack.yaml, in the section extra-dep add the following entry gtk2hs-buildtools-0.13.4.0 (or the version number you'd like to use). Then add in the package.yaml and entry gtk2hs-buildtools. It is necessary to add the entry in both files. Refer to stack docs o understand why.
Just to ensure you can build your project, your files should something look like the following:
if using resolver above or equal to 13.11
stack.yaml
resolver: lts-13.11
extra-deps:
- gtk2hs-buildtools-0.13.4.0
package.yaml
dependencies:
- base
- gtk2hs-buildtools
if using resolver below 13.11
stack.yaml
resolver: lts-12.26
extra-deps:
package.yaml
dependencies:
- base
- gtk2hs-buildtools
I'm learning Haskell and trying to setup my Emacs development environment (reading this).
One of things I should do is to install hindent.
Recommended method here is just stack install hindent. I guess it should be installed in stack's global-project space. My global stack yaml at $HOME/.stack/global-project/stack.yaml is:
flags: {}
extra-package-dbs: []
packages: []
extra-deps: []
resolver: ghc-7.10.3
I don't use any system ghc (there is no ghc or ghci on my $PATH).
On stack install hindent it adviced me to extend extra-deps:
Run from outside a project, using implicit global project config
Using resolver: ghc-7.10.3 from implicit global project's config file: /home/me/.stack/global-project/stack.yaml
While constructing the build plan, the following exceptions were encountered:
In the dependencies for hindent-5.2.1:
descriptive must match >=0.7 && <0.10, but the stack configuration has no specified version
(latest applicable is 0.9.4)
exceptions must match -any, but the stack configuration has no specified version (latest applicable is 0.8.3)
haskell-src-exts must match >=1.18, but the stack configuration has no specified version
(latest applicable is 1.18.2)
monad-loops must match -any, but the stack configuration has no specified version (latest applicable is 0.4.3)
mtl must match -any, but the stack configuration has no specified version (latest applicable is 2.2.1)
path must match -any, but the stack configuration has no specified version (latest applicable is 0.5.9)
path-io must match -any, but the stack configuration has no specified version (latest applicable is 1.2.0)
text must match -any, but the stack configuration has no specified version (latest applicable is 1.2.2.1)
unix-compat must match -any, but the stack configuration has no specified version (latest applicable is 0.4.2.0)
utf8-string must match -any, but the stack configuration has no specified version (latest applicable is 1.0.1.1)
yaml must match -any, but the stack configuration has no specified version (latest applicable is 0.8.20)
Recommended action: try adding the following to your extra-deps in /home/me/.stack/global-project/stack.yaml:
- descriptive-0.9.4
- exceptions-0.8.3
- haskell-src-exts-1.18.2
- monad-loops-0.4.3
- mtl-2.2.1
- path-0.5.9
- path-io-1.2.0
- text-1.2.2.1
- unix-compat-0.4.2.0
- utf8-string-1.0.1.1
- yaml-0.8.20
When I do what is proposed it suggests some new dependencies (which are probably dependencies of those which are added before) etc. At the end it results in situatuation where some two dependencies have unmet versions.
I presume that something is wrong with my configuration (or understanding of stack) since I think that obtaining implicit dependencies is job of a build tool.
Does someone more experienced can infer what is my beginner fault?
It's not generally recommended to use a ghc version as a resolver, for the reason you've discovered: you need to manually specify lots of package versions. Instead, I'd recommend switching to lts-6.23, or something else similar.
Not sure. If you just wanna get moving fast:
stack upgrade --git && \
rm -rf ~/.stack && \
stack setup && \
stack install hindent
Why not use GHC 8.X and a fresh new Stack? ;)
I'm creating a new Haskell project using Stack 0.1.3.1 on Windows 8. My stack.yaml file looks like this:
flags: {}
packages:
- 'lazy-engine'
extra-deps: []
resolver: lts-3.4
When I run stack build or stack test, everything works beautifully. I can run haddock manually from the command line and that works, too. But when I run stack haddock I get output like this:
Setting codepage to UTF-8 (65001) to ensure correct output from GHC
NOTE: the haddock command is functionally equivalent to 'build --haddock'
While constructing the BuildPlan the following exceptions were encountered:
-- Failure when adding dependencies:
base: needed (>=4.5 && <4.9), latest is 4.8.1.0, but not present in build plan
needed for package: array-0.5.1.0
-- While attempting to add dependency,
Could not find package base in known packages
-- Failure when adding dependencies:
array: needed (-any), latest is 0.5.1.0, but couldn't resolve its dependencies
base: needed (>=4.2 && <5), latest is 4.8.1.0, but not present in build plan
deepseq: needed (>=1.2 && <1.5), latest is 1.4.1.2, but couldn't resolve its dependencies
ghc-prim: needed (-any), latest is 0.4.0.0, but not present in build plan
needed for package: containers-0.5.6.2
-- Failure when adding dependencies:
array: needed (>=0.3 && <0.6), latest is 0.5.1.0, but couldn't resolve its dependencies
base: needed (==4.3.* || >=4.5 && <4.9), latest is 4.8.1.0, but not present in build plan
needed for package: deepseq-1.4.1.1
-- While attempting to add dependency,
Could not find package ghc-prim in known packages
-- Failure when adding dependencies:
base: needed (>=4.7 && <5), latest is 4.8.1.0, but not present in build plan
containers: needed (==0.5.*), latest is 0.5.6.3, but couldn't resolve its dependencies
needed for package: lazy-engine-0.1.0.0
Recommended action: try adding the following to your extra-deps in
C:\Users\Aaron\Documents\GitHub\lazy-engine\stack.yaml
- base-4.8.1.0
- ghc-prim-0.4.0.0
You may also want to try the 'stack solver' command
Obviously this is nonsense—I shouldn't have to add base to my extra-deps, especially since I'm working off an LTS package set! What is going on here?
Update: As discussed in the answer below, this seems to have been a bug in stack and should be fixed in newer versions. See https://github.com/fpco/minghc/issues/85.
A guess: you're using a GHC install that does not include documentation, or at least not as stack expects it to be discovered. Can you try with "--install-ghc --no-system-ghc"? I may have the specific flag names wrong.
Also, how is GHC installed on your system?
I solved this by installing the ghc-doc package (available in most package managers).
Using cabal, I could install hakyll with the command:
cabal install hakyll
How can I do the same thing using stack?
stack install hakyll
stack offers a curated set of packages that won't blow your machine up. If you want to check what packages are available, or exactly what version is supported, or on what version of GHC you can get it, check out https://www.stackage.org/.
For example, you can get hakyll 4.6.9.0 right now for both GHC 7.8.4 and GHC 7.10.1. Pretty neat. - source
EDIT: I forgot to mention, Yuan Wang's method works for getting the version of hakyll that is not curated into stackage. It's up to you what version you need.
add hakyll in stack.yaml generated by stack init or stack new
yaml file should look like:
flags: {}
packages:
- '.'
extra-deps:
- hakyll-4.7.1.0
resolver: lts-2.15
after that, run stack solver installs it
https://github.com/commercialhaskell/stack/wiki/stack.yaml
This documentation worked for me
On package.yaml add the library under dependencies, for example:
dependencies:
- base >= 4.7 && < 5
- hakyll # added here