stack.yaml not pulling in dependency from github - haskell

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.

Related

Trouble including tasty-quickcheck in the build

I am new to stack.
I have a stack project that I want to use tasty-quickcheck. When I add tasty-quickcheck to package.yaml, stack asks me to add it to stack.yaml as well under extra-deps section. After adding tasty-quickcheck-0.10.1.1 to extra-deps stack asked me to add around a dozen more packages to extra-deps which I added.
Now I am at a stage where I get the following error when I try to do stack build.
stack build
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for transformers-compat-0.6.5:
transformers-0.5.6.2 from stack configuration does not match >=0.3 && ==0.2.*
needed due to tic-tac-toe-0.1.0.0 -> transformers-compat-0.6.5
Some different approaches to resolving this:
* Set 'allow-newer: true'
in /Users/home/.stack/config.yaml to ignore all version constraints and build anyway.
Plan construction failed.
My package.yaml looks like below.
...
dependencies:
- base >= 4.7 && < 5
- vector
- mtl
- tasty-quickcheck
...
My stack.yaml looks like below.
...
resolver: ghc-8.8.3
extra-deps:
- vector-0.12.1.2
- primitive-0.7.0.1
- tasty-quickcheck-0.10.1.1
- random-1.1
- tagged-0.8.6
- tasty-1.3.1
- QuickCheck-2.14
- ansi-terminal-0.10.3
- async-2.2.2
- clock-0.8
- optparse-applicative-0.15.1.0
- unbounded-delays-0.1.1.0
- wcwidth-0.0.2
- ansi-wl-pprint-0.6.9
- colour-2.3.5
- hashable-1.3.0.0
- splitmix-0.0.5
- transformers-compat-0.6.5
...
I have two questions.
How do I fix the error above?
Is it usual that stack tells you to add a dozen more dependencies just to get a single package like tasty-quickcheck included? That doesn't sound great to me. Is that the norm with most packages?
Quoting a comment:
Which resolver (or snapshot) is specified in your stack.yaml?
#duplode It is resolver: ghc-8.8.3
You presumably don't want to use the ghc-* resolvers in this case. They only specify the GHC version (and the version of small handful of packages which are bundled with GHC), which is why you had to add everything else to extra-deps. Change the resolver to lts-16.0 (the most recent Stackage LTS, which does include tasty-quickcheck-0.10.1.1), remove the extra-deps from the stack.yaml file; that should be enough for things to work.

How can I access python3.6+ from Haskell?

haskell-cpython works up to python3.4, but it is a too old version of python. The library also seems not to be maintained anymore.
It is possible to download a more recent version at this fork changing package.yaml
dependencies:
- cpython
and also stack.yaml
extra-deps:
- github: ekalosak/haskell-cpython
commit: 829da05dc5117b2f1d15fdcbd9796b1a65f53c3d

Is there a way to point on servant-server 0.15 that is not yet on the last haskell LTS?

I would like to use the version 0.15 instead of the the one available on the last LTS (12.22), usually I'm adding this in stack.yaml :
extra-deps :
- git: git#github.com:haskell-servant/servant.git
commit: e3e5d2b23057c2c3409e5e210b613527baf3b77d
But they use multiple projects in the same repo so it does not work :-( :
The current entry points to
/Users/nhenin/dev/gsdFlow/.stack-work/downloaded/6krbU6UwORFF/ but no .cabal or package.yaml file could be found there.
Do you know how I could use it ?
All you need to do is specify sub directories in the repository containing the project:
extra-deps:
- git: git#github.com:haskell-servant/servant.git
commit: e3e5d2b23057c2c3409e5e210b613527baf3
subdirs:
- servant
if you needed servant-pipes from the repository as well, for instance, you'd also include it in the list:
...
subdirs:
- servant
- servant-pipes
You can use subdirs subfield to tell stack what project you want to add. See https://github.com/eta-lang/dhall-to-etlas/blob/master/stack.yaml f.e.

Haskell Stack: The following package identifiers were not found in your indices

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.

Cannot add extra-deps to Stack project

I'm trying to set up a Haskell project with Stack. I have created a project: stack new project1 and added the suggested dependency (acme-missile) just to see how it works.
extra-deps:
- acme-missiles-0.3
But when I try to invoke launchMissile in the Main it won't work. I get
Error:(3, 1) Could not find module ‘Acme.Missiles’
Use -v to see a list of the files searched for.
|
3 | import Acme.Missiles
| ^^^^^^^^^^^^^^^^^^^^
What is the problem? What am I missing?
EDIT
When I run stack solver I get this:
Using configuration file: stack.yaml
Using cabal packages:
- ./
The following changes will be made to stack.yaml:
* Dependencies to be deleted
extra-deps:
- acme-missiles-0.3
To automatically update stack.yaml, rerun with '--update-config'
Isn't that strange? Like it thinks my dependency is not needed?
You'll need to add the dependency to project1.cabal as well:
build-depends:
base >=4.7 && <5
, project1
, acme-missiles
Alternatively, on newer versions of Stack, it looks like you should use package.yaml instead:
dependencies:
- base >= 4.7 && < 5
- acme-missiles
I can't say that I have deep knowledge of how this works, but if I understand it correctly, the main file where you're supposed to add dependencies is in the .cabal or package.yaml file. The extra-deps field in stack.yaml is where you can indicate if you have dependencies that deviate from the LTS that you currently use.

Resources