Stack doesn't seem to apply package revision - haskell

I had the following (excerpt of) stack.yaml:
extra-deps:
- bytestring-0.10.12.0
Then I wanted to install cassava, which I did by adding:
extra-deps:
- bytestring-0.10.12.0
- cassava-0.5.2.0
But then I had this error on stack build:
In the dependencies for cassava-0.5.2.0:
bytestring-0.10.12.0 from stack configuration does not match >=0.9.2 && <0.10.4 (latest matching version is 0.10.2.0)
needed due to my-project-0.1.0.0 -> cassava-0.5.2.0
To which I discovered that there's a revision (all of them from rev2 onwards) that deals with this explicit problem, by bumping the dependency on ByteString to <0.12.
Therefore stack.yaml now looks like this:
extra-deps:
- bytestring-0.10.12.0
- cassava-0.5.2.0#rev:4
But nothing changes on stack build, I still got the same error. Is there any way around this?

Related

transformers-0.5.6.2 from stack configuration does not match >=0.3 && ==0.2.*

I'm trying to include quickcheck-instances package for testing. Here is how my dependencies field in package.yaml looks like:
dependencies:
- blackjack
- quickcheck-instances >= 0.3.25 && < 0.4
- QuickCheck >= 2.14.2 && < 2.15
Here is how my extra-deps field in stack.yaml looks like:
extra-deps:
- quickcheck-instances-0.3.25.2#sha256:083b84b91fccb3bbf22cd906f5bc731c8e6ee96c7554e892985452f2d61d4ad3,4484
- hashable-1.3.3.0#sha256:7f3b67151162a1dfe8472dc30430af98ed5470801d3f4b6c9b8d7a7443c920d4,4068
- unordered-containers-0.2.14.0#sha256:2fe789f78246b7c7ec10d7b85c72d898a9f72fdda5b60d581e839d21016bc628,4992
- QuickCheck-2.14.2#sha256:4ce29211223d5e6620ebceba34a3ca9ccf1c10c0cf387d48aea45599222ee5aa,7736
- case-insensitive-1.2.1.0#sha256:9dfd3171fc7698cf8d931727d3af3a7b389135b583e46b5adac1f9d2026fff61,2244
- data-fix-0.3.2#sha256:ca5ee8d5e15d08e65e9af74004cd663391706c0a62b7d1c6d0023e4c34cd0038,1659
- integer-logarithms-1.0.3.1#sha256:888fb6c4fbd79ed2e8f8b94b61bccac25f7fab2b13b32b496e86828bc60b17cf,3184
- old-time-1.1.0.3#sha256:c91fbb3ee73d20ccd015842b30f1f29a304893ebe0ae3128b7bbc13d5bb0d4c8,1328
- scientific-0.3.7.0#sha256:0f188a7b92780d81a2e3cf1195a3a24cfe3e7c43d0e9e0f2101a465803d68076,4773
- splitmix-0.1.0.3#sha256:fc3aae74c467f4b608050bef53aec17904a618731df9407e655d8f3bf8c32d5c,6049
- strict-0.4.0.1#sha256:50187e750751a258efea12ef2979e16a014a953c15bf4c2fca2f1168a44a5a12,4156
- tagged-0.8.6.1#sha256:29c67d98a4404607f024750ab9c7210dadcbbef4e1944c48c52902f2071b2662,2874
- these-1.1.1.1#sha256:bdc0a3015b2e5cdf016e402937d71856ae5fe4e9e9a0d4823cc94a214c55a39b,2732
- time-compat-1.9.6.1#sha256:cddf1a7654ccc3564d2197e6bf0064254abf792c591a9fa0eaa16e6039036152,4997
- uuid-types-1.0.5#sha256:5031383749d57cb95877d7e56f0300be66652b6e57f5ba6681dcc6e4f78d046d,2541
- vector-0.12.3.0#sha256:0ae2c1ba86f0077910be242ec6802cc3d7725fe7b2bea6987201aa3737b239b5,7953
- assoc-1.0.2#sha256:a824e4f615469a27ad949dbf4907ba258bd6b459deebec00524c7bcb3f65cc9f,1205
- base-orphans-0.8.5#sha256:b01baac1b88cc80e70214c064ec8c174718c19400232588bff591f5a9c49a750,3177
- old-locale-1.0.0.7#sha256:fa998be2c7e00cd26a6e9075bea790caaf3932caa3e9497ad69bc20380dd6911,1071
- primitive-0.7.2.0#sha256:d7c3635e83ae160129cdfe2be4092ab6389199d73a2c29adf904124dbcfe6100,2660
- random-1.2.0#sha256:195506fedaa7c31c1fa2a747e9b49b4a5d1f0b09dd8f1291f23a771656faeec3,6097
- bifunctors-5.5.11#sha256:cc425ee85aae56dba1123baf6fb3fa7abcd90782f26bb904eef14c7332ee85f6,3919
- comonad-5.0.8#sha256:1f1aabd73ec7f80f20cf078a748a60cd48d8e57277802fdf6a9ab3601a9b8f7e,3631
- th-abstraction-0.4.3.0#sha256:db4b3b69398acd8a7c5c8cc8a962da55d65d05d44d5039b51bd3cb5fb3d8400f,2148
- distributive-0.6.2.1#sha256:0f99f5541cca04acf89b64432b03422b6408e830a8dff30e6c4334ef1a48680c,2996
- indexed-traversable-0.1.1#sha256:e4602357513aa3b146546227732e6e5698392f4324ab690e109cc05676ba3b4f,2491
- transformers-compat-0.6.6#sha256:510709db2b12d1510d70de824ee544ca0a9e6f27aa7e299218cbacc0750b4a5e,5560
- transformers-0.5.6.2#sha256:6c959d14430f4deffb99579ba019de07c3d852a2122b6f449344386c7d75ff1d,3172
This is the error I got:
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for transformers-compat-0.6.6:
transformers-0.5.6.2 from stack configuration does not match >=0.3 && ==0.2.*
needed due to blackjack-0.1.0.0 -> transformers-compat-0.6.6
Some different approaches to resolving this:
* Set 'allow-newer: true' in /home/xwtek/.stack/config.yaml to ignore all version constraints and build anyway.
Plan construction failed.
Of course after setting the allow-newer into true, it works, but I don't want to mess with that setting, because I fear that something like that would make things break later. Any better solution?
Clearly, you are missing how stack works. You should read the stack user guide, but let me explain briefly. stack uses two files to work:
stack.yaml: It defines from where stack should download packages. By default Stackage. Optionally, git repos, hackage or local libraries.
package.yaml: It defines which libraries you'll be using along with how to build your executable. Dependencies, compiler flags, test, etc...
In general the only thing you need to touch from stack.yaml is the resolver, and then use package.yaml to list your dependencies. So, How does stack.yaml is used?
You should have a line like this
resolver:
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/6.yaml
This specifies the set of packages you gonna use, called: resolver or snapshot. All libraries version within an snapshot are guaranteed to build togheter with no dependency hell. In the example above the resolver is set to lts-18.6. So, If you visit stackage page for that snapshot you'll see all suported libraries and the compiler version: ghc-8.10.4
So let say I want to add QuickCheck to my dependencies. In my package.yaml I would list it down the library dependencies label
library:
dependencies:
- QuickCheck
The version of QuickCheck is determine by the selected resolver (18.6) which in this case is QuickCheck-2.14.2 as you can check in the stackage web. Of course, it is a good practise to specify the actual version in package.yaml
library:
dependencies:
- QuickCheck-2.14.2
But it is not necessary, since the resolver already sets the version from you. If you need another version of the package, then you have to add it to extra-deps, indicating stack that you want packages from lts-18.6 and a different package listed in extra-deps
The stack documentation is fairly good, so you should read it more carefully.

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 to resolve dependency tree with different version ranges of same packages?

I'm trying to set up a happstack-lite application using stack.
I initialized project with these commands:
stack new my-happstack
cd my-happstack
stack setup
I changed package.yaml so it contains:
dependencies:
- base >= 4.7 && < 5
- happstack-lite >= 7.3
Then I ran stack build several times and changed extra-deps in stack.yaml in project directory according to recommendations (added dependencies, such as happstack-server).
Apparently, I was asked to add to extra-deps the packages already listed there, with different version bounds and one with the same (template-haskell-2.11.1.0):
stack.yaml content:
extra-deps:
- happstack-lite-7.3.6
- happstack-server-7.4.6.4
- Win32-2.2.2.0#sha256:10ed55dd31315f386910c121c1d1d442df83bd2ee92090a753cd65300735a8ca
- network-2.6.3.6#sha256:1ca79d81af02d7acd6032d5e6c9bde4618a8fdcfbe19bd42b49d420183975df0
- template-haskell-2.11.1.0#sha256:f90d6ab73ad35c749e8547ca132e7ab5d32d2f8e7bb2e2ff6d597be26b58e061
- transformers-compat-0.5.1.4#sha256:1b4bfa8589afb1ca0e719129ab261bd90ef0cc3e6c0b9963f94970c082b61250
output from stack build:
F:\Projects\Haskell\my-happstack>stack build
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for Cabal-2.4.1.0:
Win32-2.2.2.0 from stack configuration does not match >=2.3.0.0 && <2.9 (latest matching
version is 2.8.3.0)
needed due to my-happstack-0.1.0.0 -> Cabal-2.4.1.0
In the dependencies for happstack-server-7.4.6.4:
template-haskell-2.14.0.0 from stack configuration does not match <2.12 (latest matching
version is 2.11.1.0)
needed due to my-happstack-0.1.0.0 -> happstack-server-7.4.6.4
In the dependencies for transformers-base-0.4.5.2:
transformers-compat-0.5.1.4 from stack configuration does not match >=0.6.1 (latest matching
version is 0.6.4)
needed due to my-happstack-0.1.0.0 -> transformers-base-0.4.5.2
Some different approaches to resolving this:
* Set 'allow-newer: true' in C:\sr\config.yaml to ignore all version constraints and build anyway.
* Consider trying 'stack solver', which uses the cabal-install solver to attempt to find some
working build configuration. This can be convenient when dealing with many complicated
constraint errors, but results may be unpredictable.
* Recommended action: try adding the following to your extra-deps
in F:\Projects\Haskell\my-happstack\stack.yaml:
Win32-2.8.3.0#sha256:58fa6f52e8a0d455a74bb19445c177f2cc79a0975cae5fd96e2334bd38a516d4
template-haskell-2.11.1.0#sha256:f90d6ab73ad35c749e8547ca132e7ab5d32d2f8e7bb2e2ff6d597be26b58e061
transformers-compat-0.6.4#sha256:d298cd9d1bb7b05160229e244436bae825b53660865e3d5fd695ea0fafec1e6f
Plan construction failed.
I've tried these steps:
1) Set 'allow-newer: true' in C:\sr\config.yaml. In this case, I'm getting error about wrong types usage from inside one of the dependent packages (can paste error output upon request, if needed).
2) Run stack solver. I've got the error from cabal planner (error output upon request).
So, I expect stack to resolve dependencies the way npm does - each package dependencies are resolved independently from other's packages needs. Any advice of how I can solve this particular problem will be helpful, though (including manual dependencies resolving).

stack install ghc-mod fails with dependencies conflicts on OSX 10.13.4

When I try to install ghc-mod via stack I end up having these depencies conflicts
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for ghc-mod-5.8.0.0:
Cabal-2.0.1.1 from stack configuration does not match >=1.18 && <1.25 (latest matching version is 1.24.2.0)
base-4.10.1.0 from stack configuration does not match >=4.6.0.1 && <4.10 (latest matching version is 4.9.1.0)
cabal-helper must match <0.8 && >=0.7.3.0, but the stack configuration has no specified version (latest matching version is 0.7.3.0)
extra-1.6.8 from stack configuration does not match <1.6 && >=1.4 (latest matching version is 1.5.3)
ghc-8.2.2 from stack configuration does not match >=7.6 && <8.2
haskell-src-exts-1.20.2 from stack configuration does not match <1.20 && >=1.18 (latest matching version is 1.19.1)
hlint-2.1.6 from stack configuration does not match <2.1 && >=2.0.8 (latest matching version is 2.0.15)
monad-journal-0.8.1 from stack configuration does not match <0.8 && >=0.4 (latest matching version is 0.7.2)
optparse-applicative-0.14.2.0 from stack configuration does not match >=0.13.0.0 && <0.14 (latest matching version is 0.13.2.0)
needed since ghc-mod is a build target.
Some different approaches to resolving this:
* Consider trying 'stack solver', which uses the cabal-install solver to attempt to find some working build configuration. This can be convenient when dealing with many complicated constraint
errors, but results may be unpredictable.
* Recommended action: try adding the following to your extra-deps in /Users/mo/.stack/global-project/stack.yaml:
- Cabal-1.24.2.0
- base-4.9.1.0
- cabal-helper-0.7.3.0
- extra-1.5.3
- haskell-src-exts-1.19.1
- hlint-2.0.15
- monad-journal-0.7.2
- optparse-applicative-0.13.2.0
if I try to add the suggested extra deps like so
extra-deps:
- Cabal-1.24.2.0
- base-4.9.1.0
- cabal-helper-0.7.3.0
- extra-1.5.3
- haskell-src-exts-1.19.1
- hlint-2.0.15
- monad-journal-0.7.2
- optparse-applicative-0.13.2.0
- process-1.4.3.0
- either-4.4.1.1
- free-4.12.4
I end up having a loop like this
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for ghc-mod-5.8.0.0:
base-4.10.1.0 from stack configuration does not match >=4.6.0.1 && <4.10 (latest matching version is 4.9.1.0)
ghc-8.2.2 from stack configuration does not match >=7.6 && <8.2
needed since ghc-mod is a build target.
In the dependencies for haskell-src-exts-util-0.2.3:
haskell-src-exts-1.19.1 from stack configuration does not match >=1.20.0 (latest matching version is 1.20.2)
needed due to ghc-mod-5.8.0.0 -> haskell-src-exts-util-0.2.3
In the dependencies for hlint-2.0.15:
haskell-src-exts-1.19.1 from stack configuration does not match >=1.20 && <1.21 (latest matching version is 1.20.2)
needed due to ghc-mod-5.8.0.0 -> hlint-2.0.15
Some different approaches to resolving this:
* Set 'allow-newer: true' to ignore all version constraints and build anyway.
* Consider trying 'stack solver', which uses the cabal-install solver to attempt to find some working build configuration. This can be convenient when dealing with many complicated constraint
errors, but results may be unpredictable.
* Recommended action: try adding the following to your extra-deps in /Users/mo/.stack/global-project/stack.yaml:
- base-4.9.1.0
- haskell-src-exts-1.20.2
if i put - haskell-src-exts-1.20.2 they ask me for - haskell-src-exts-1.19.1 back and vice versa I can't figure out what to do about this dependency conflict, and also I tried to run stack resolver but it doesn't get me anywhere
The issue is that ghc-mod does not support newer versions of GHC, I believe the last supported version is GHC 8.0. You can try changing your Stack resolver to lts-8.24 or nightly-2017-06-28 (see the snapshots listed on ghc-mod's Stackage page).
Even easier, this worked for me:
stack install ghc-mod --resolver lts-8.24
input command line:
stack install ghc-mod --resolver lts-8.24
it really helps.

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.

Resources