I'm trying to build a haskell project using stack. After running stack setup, which seems to installs GHC fine, I ran stack build and encountered the following error:
Didn't see language-c-0.5.1 in your package indices.
Updating and trying again.
Selected mirror https://s3.amazonaws.com/hackage.fpcomplete.com/
Downloading timestamp
No updates to your package index were found
Update complete
The following package identifiers were not found in your indices: language-c-0.5.1
Possible candidates: language-c-0.5.0.
I'm not sure why that is. Running stack ghci also gives the exact same message. (But running stack ghc outputs ghc: no input files as expected).
I have tried removing ~/.stack/indices, but that didn't fix the problem.
Here's my stack version information
⇒ stack --version
Version 1.6.3, Git revision b27e629b8c4ce369e3b8273f04db193b060000db (5454 commits) x86_64 hpack-0.20.0
The local GHC version is 7.10.3
Here's my stack.yaml, excluding some commented sections
# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)
resolver: lts-6.12
# Local packages, usually specified by relative directory name
packages:
- .
- ./compdata
- ./comptrans
- ./compstrat
- location:
git: git#github.com:jkoppel/language-java.git
commit: 68e71843294b233c36b3cbe52d9b1e35a5898997
extra-dep: true
- location:
git: git#github.com:dvekeman/language-c.git
commit: caf4888d6c32d97f57d5107db3369e90b5d2649e
extra-dep: true
- location:
git: git#github.com:bjpop/language-python.git
commit: 9269c77ca67c52280314a122cae1b3fa1a044168
extra-dep: true
# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)
extra-deps: [language-lua-0.10.0, language-python-0.5.4, language-java-0.2.8, language-javascript-0.6.0.9, language-c-0.5.1, language-dot-0.1.0, fgl-5.5.3.0]
# Override default flag values for local packages and extra-deps
flags: {}
# Extra package databases containing global packages
extra-package-dbs: []
Take a look at the versions on hackage - https://hackage.haskell.org/package/language-c - 0.5.1 doesn't exist.
Related
I have projects compiling with cabal build (but using hpack for the convenience). For some reason, I would like to compile them with stack build. What goes into a minimal stack.yaml file?
The stack documentation gives details what goes into such a file, but does not show a minimal (or any, as much as I can see) example. I fear to use stack init on an existing project for unintended consequences.
What is a small example from which to go?
A minimal stack.yaml:
resolver: lts-19.16 # for ghc 9.0.2 newest lts
packages:
- .
A not-so minimal skeleton from which to expand:
resolver: lts-19.16 # for ghc 9.0.2 newest lts
packages:
- .
extra-deps: # include here other local packages
ghc-options:
"$everything": -haddock # to produce documentation with haddock
Here's the stack.yaml stanza
packages:
- location:
git: https://github.com/TwitterFriends/lsh.git
commit: 57d57f4209e56f526c0eca023907015935c26071
extra-dep: true
I add the package to cabal file
get error when I try to build
While constructing the BuildPlan the following exceptions were encountered:
-- While attempting to add dependency,
Could not find package lsh in known packages
What am I doing wrong?
Current project found here
https://github.com/TwitterFriends/twitter-friend-server
The problem is syntax. You added some extra spaces before extra-dep. Place this in stack.yaml. With this, your project builds on my machine.
- location:
git: https://github.com/TwitterFriends/lsh.git
commit: 57d57f4209e56f526c0eca023907015935c26071
extra-dep: true
UPDATE: (17 Dec 2017)
Since stack-1.6.1 syntax of adding github dependency is changed. You need to add your github dependency into extra-deps field. Something like this:
resolver: lts-9.17
packages: [.]
extra-deps:
- fmt-0.5.0.0
- git: https://github.com/TwitterFriends/lsh.git
commit: 57d57f4209e56f526c0eca023907015935c26071
UPDATE: (5 Dec 2019)
In stack-2.1.3 you can specify GitHub dependencies in extra-deps with even shorter syntax:
extra-deps:
- github: TwitterFriends/lsh
commit: 57d57f4209e56f526c0eca023907015935c26071
It looks like the problem you're facing is due to a syntax error in the lines in your stack.yaml file directly preceding those you posted in the question.
When I visited your repo and checked out the whole stack.yaml file, I saw this:
resolver: lts-8.13
# User packages to be built.
# Various formats can be used as shown in the example below.
#
packages:
# - https://example.com/foo/bar/baz-0.0.2.tar.gz
- location:
git: https://github.com/TwitterFriends/lsh.git
commit: 57d57f4209e56f526c0eca023907015935c26071
extra-dep: true
This packages: line doesn't look right, especially given that later in the file you have:
packages:
- '.'
So my best guess would be that the stack.yaml file isn't getting parsed correctly, so it can't find the library b/c it doesn't know it should grab it from that location.
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.
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