Haskell dependency hell - haskell

I'm trying to include a specific version of a library in a Haskell project. The library is bed-and-breakfast (which is used for martix operations), but I need the specific version 0.4.3 which fixed a bug with the multiplication implementation.
So, my stack.yaml looks like this:
flags: {}
extra-package-dbs: []
packages:
- .
extra-deps:
- bed-and-breakfast-0.4
- base-4.6.0.1
resolver: lts-12.8
But I'm getting this error when building:
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for bed-and-breakfast-0.4:
base-4.11.1.0 from stack configuration does not match >=4.5 && <4.7 (latest matching version
is 4.6.0.1)
needed due to realworldhaskell-0.1.0.0 -> bed-and-breakfast-0.4
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 C:\Users\info\Desktop\Projects\haskell\stack.yaml:
- base-4.6.0.1
I've done the recommended action but it didn't solve anything. I've tried using different resolvers to see if it's an issue with my GHCi version but nothings worked. What is the best way to interpret error messages like this and how should I proceed?
EDIT:
If I remove -base.4.6.0.1 and add allow-newer: true I get this:
WARNING: Ignoring out of range dependency (allow-newer enabled): base-4.11.1.0. bed-and-breakfast requires: >=4.5 && <4.7
bed-and-breakfast-0.4: configure
Progress 1/2
-- While building custom Setup.hs for package bed-and-breakfast-0.4 using:
C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_2.2.0.1_ghc-8.4.3.exe --builddir=.stack-work\dist\7d103d30 configure --with-ghc=C:\Users\info\AppData\Local\Programs\stack\x86_64-windows\ghc-8.4.3\bin\ghc.EXE --with-g
hc-pkg=C:\Users\info\AppData\Local\Programs\stack\x86_64-windows\ghc-8.4.3\bin\ghc-pkg.EXE --user --package-db=clear --package-db=global --package-db=C:\sr\snapshots\76fd1958\pkgdb --package-db=C:\Users\info\Desktop\Projects\haskell\
.stack-work\install\8c390635\pkgdb --libdir=C:\Users\info\Desktop\Projects\haskell\.stack-work\install\8c390635\lib --bindir=C:\Users\info\Desktop\Projects\haskell\.stack-work\install\8c390635\bin --datadir=C:\Users\info\Desktop\Proj
ects\haskell\.stack-work\install\8c390635\share --libexecdir=C:\Users\info\Desktop\Projects\haskell\.stack-work\install\8c390635\libexec --sysconfdir=C:\Users\info\Desktop\Projects\haskell\.stack-work\install\8c390635\etc --docdir=C:
\Users\info\Desktop\Projects\haskell\.stack-work\install\8c390635\doc\bed-and-breakfast-0.4 --htmldir=C:\Users\info\Desktop\Projects\haskell\.stack-work\install\8c390635\doc\bed-and-breakfast-0.4 --haddockdir=C:\Users\info\Desktop\Pr
ojects\haskell\.stack-work\install\8c390635\doc\bed-and-breakfast-0.4 --dependency=array=array-0.5.2.0 --dependency=base=base-4.11.1.0 --dependency=binary=binary-0.8.5.1 --dependency=deepseq=deepseq-1.4.3.0 --dependency=template-hask
ell=template-haskell-2.13.0.0 --extra-include-dirs=C:\Users\info\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include --extra-lib-dirs=C:\Users\info\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\min
gw64\bin --extra-lib-dirs=C:\Users\info\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\lib --exact-configuration
Process exited with code: ExitFailure 1
Logs have been written to: C:\Users\info\Desktop\Projects\haskell\.stack-work\logs\bed-and-breakfast-0.4.log
Configuring bed-and-breakfast-0.4...
Cabal-simple_Z6RU0evB_2.2.0.1_ghc-8.4.3.exe: The package has an impossible
version range for a dependency on an internal library: bed-and-breakfast
==0.3.2. This version range does not include the current package, and must be
removed as the current package's library will always be used.
EDIT 2:
Ok, so I'm guessing that the bed-and-breakfast library needs base 4.11.1.0 which is included in GHCi 6.10.2 (according to https://wiki.haskell.org/Base_package) so I need a resolver which matches that GHCi version. Where can I find out what resolver version that is?

Here is the constraint on the latest available bed-and-breakfast package: base (>=4.5 && <4.7), which means it will likely not even compile with GHC version higher then 7.6. Considering that there is even no LTS snapshot prior to GHC 7.8, you are out of luck with that package.
To say it in another words, the package is outdated and your choices are:
submit an issue and hope maintainer will do something about it
try to make it work with newer ghc yourself
Use a different package

Related

Building the Spock tutorial example fails

I wanted to get going with Haskell a little bit and therefore took a look at the Spock framework. To start clean, I uninstalled everything Haskell related from my Arch Linux machine and installed ghcup, Cabal and Stack using the install scripts from their respective websites.
Now I want to follow Spock's Tutorial. Trying to install Spock globally with cabal install Spock as suggested gives me an error (abbreviated):
src/Web/Spock/Internal/Wire.hs:43:1: error:
Could not find module ‘Web.Routing.AbstractRouter’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
43 | import Web.Routing.AbstractRouter
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cabal: Failed to build Spock-0.9.0.1. See the build log above for details.
I already found a question on reddit on the topic, but the solution does not apply because I'm not trying to use a specific version of the libraries as implied.
So I try to follow along and build only locally.
But when I reach the point where it says stack build --fast --pedantic, the build plan can not be constructed and Stack suggests to add another dependency, stm-containers. Doing so, I am presented with two additional suggestions for focus and primitive. When I add these, the plan fails again, this time without a simple solution:
In the dependencies for primitive-0.6.4.0:
base-4.13.0.0 from stack configuration does not match >=4.5 && <4.13 (latest matching version is 4.12.0.0)
needed due to Spock-example-0.1.0.0 -> primitive-0.6.4.0
I can do a little thing with Haskell, but with the build system(s), I am way out of my comfort zone. Help and hints appreciated. Oh, and all versions of course are the latest by the time of this post.
Due to incompatible versions of dependencies, Spock won't build with GHC 8.8 and above. A similar problem is described in Spock issue #149, though I'm not fully sure it is exactly the same incompatibility. The error you got from Stack hints at that, as base-4.13.0.0 is the version of base that is bundled with GHC 8.8. cabal-install failed in a more obscure way because, upon noting the incompatibility, it tries to solve the dependencies using older versions of Spock, eventually picking 0.9.0.1, attempting and, thanks to a missing version upper bound for the reroute dependency, failing to build it.
(Shortly after this answer was posted, the missing upper bound was retrofitted to the old Spock version, so attempting to reproduce the problem now will lead to an easier to understand failure.)
Casting the tutorial aside, the most straightforward way to use Spock given those complications is probably through cabal-install 3+. Begin by using ghcup to switch to GHC 8.6.5:
$ ghcup install 8.6.5
$ ghcup set 8.6.5
Then, create a blank project with cabal-install:
$ mkdir myproject
$ cd myproject
$ cabal init
Add Spock to the build-depends section of myproject.cabal:
build-depends: base >=4.12 && <4.13
, Spock == 0.13.*
Finally, you can run:
$ cabal build
Which will install Spock and its dependencies before building the project. (Note that you generally don't need to use cabal install to install libraries with cabal-install 3.)
It is presumably possible to make it work with Stack as well, by changing to the lts-14.27 resolver (the latest one that uses GHC 8.6.5), tracking down all dependency versions that need to be overriden (as you had began to do) and manually adding them to the extra-deps of stack.yaml.

stack does not resolve dependencies when installing hip

I want to install the Haskell libary hip from https://hackage.haskell.org/package/hip by using stack. This does not work, because stack seems to not being able to install dependencies.
I have stack freshly installed by curl -sSL https://get.haskellstack.org/ | sh, and stack --version gives me
Version 1.9.3, Git revision 40cf7b37526b86d1676da82167ea8758a854953b (6211 commits) x86_64 hpack-0.31.1
I have tried several things like another resolver, reinstalling different versions of stack, ghc or cabal.
I have tried stack new test, and inside the test folder, i wrote stack install hip.
I got the following error:
Error: While constructing the build plan, the following exceptions were
encountered:
In the dependencies for hip-1.5.3.0:
Chart must match >=1.5, but the stack configuration has no specified
version (latest matching version is 1.9)
Chart-diagrams must match >=1.5, but the stack configuration has no
specified version (latest matching version is 1.9)
needed since hip 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 /home/jarek/Desktop/test/stack.yaml:
Chart-1.9#sha256:f41568b6b3704f66c2ec163295b430ab7d798f91de426c2d5aba747d1135cd9b
Chart-diagrams-1.9#sha256:cdd0c22d730e507f9644e690833096ee127302b5ff5e1571f6def419160a2642
Plan construction failed.
I expect something like:
Building dependencies...
Installing Chart-1.9
...
...
...
hip successfully installed.
Please tell me if i did not provide all infos necessary for you to help me with my problem.
Installing with the resolver lts-7.5 works.
Why not do what stack recommended?
Recommended action: try adding the following to your extra-deps
in /home/jarek/Desktop/test/stack.yaml:
Chart-1.9#sha256:f41568b6b3704f66c2ec163295b430ab7d798f91de426c2d5aba747d1135cd9b
Chart-diagrams-1.9#sha256:cdd0c22d730e507f9644e690833096ee127302b5ff5e1571f6def419160a
It's the easiest way to accomplish your goal.
Update: lts-10.10 is the most recent resolver to include hip. If you update your stack.yaml to use lts-10.10 and add hip in your .cabal file, you should be good to go.

Why can't I use Text.Regex in my Stack project?

All I want is to parse a simple string using regex.
First question: Should I be using Text.Regex or something else? Stackage lists at least 11 regex packages. I don't care if it's PCRE or Posix. At this point I'll accept anything.
Second Question: How do I include Text.Regex in my project? This is my experience so far:
package.yaml has
dependencies:
- base >= 4.7 && < 5
- regex
stacky.yaml attempt 1
extra-deps:
- regex-1.0.1.3
Response to stack build
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for regex-1.0.1.3:
base-compat-0.10.5 from stack configuration does not match >=0.6 && <0.10 (latest matching version is 0.9.3)
template-haskell-2.13.0.0 from stack configuration does not match >=2.7 && <2.12 (latest matching version is 2.11.1.0)
needed due to CCompiler-0.1.0.0 -> regex-1.0.1.3
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/adamfrank/Dev/Haskell/CCompiler/stack.yaml:
- base-compat-0.9.3
- template-haskell-2.11.1.0
Plan construction failed.
stack.yaml attempt 2
extra-deps:
- regex-1.0.1.3
- base-compat-0.9.3
- template-haskell-2.11.1.0
Response to stack build:
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for regex-1.0.1.3:
template-haskell-2.13.0.0 from stack configuration does not match >=2.7 && <2.12 (latest matching version is 2.11.1.0)
needed due to CCompiler-0.1.0.0 -> regex-1.0.1.3
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/adamfrank/Dev/Haskell/CCompiler/stack.yaml:
- template-haskell-2.11.1.0
Plan construction failed.
???
It says I need to add a line I already added.
Do I need a different version of regex? If so, which one, and how do I figure that out?
There are a few recommendations in the comments as to what to use: regex-base, but it is also good to understand why it is not compiling.
Stackage provides a list of compatible packages in each LTS. You can alter some of the version numbers as long as they respect the version constraints of other dependencies. Not all of these dependency restrictions are well defined in the packages coming from Hackage, which is one of the reasons for using Stackage.
Generally each stackage major LTS release is associated with a particular version of GHC which also has a particular version of base. When you pick a major version of LTS, you are also picking a version of GHC and base. If you want to change GHC and/or base versions, it is easier to change the LTS version. The first thing after the LTS version on the Stackage LTS page is the GHC version number.
In your case regex requires a version of template-haskell and base-compat that violate the constraints of other dependencies.

Why am I getting build plan errors running "stack haddock" when "stack test" works?

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).

Cannot resolve the dependency about yesod-auth-oauth package

I want to use Yesod web framework with yesod-auth-oauth, but I encountered a dependency problem while cabal-dev install:
/Users/kenta/myapp/oryza% cabal-dev install
Resolving dependencies...
cabal: cannot configure yesod-platform-1.0.2. It requires data-default ==0.4.0
For the dependency on data-default ==0.4.0 there are these packages:
data-default-0.4.0. However none of them are available.
data-default-0.4.0 was excluded because authenticate-oauth-1.3.0 requires
data-default ==0.3.*
data-default-0.4.0 was excluded because data-default-0.3.0 was selected
instead
data-default-0.4.0 was excluded because oryza-0.0.0 requires data-default
==0.3.*
I don't have any idea of what's wrong.
What I did is just inserting one line in Cabal file:
yesod-auth-oauth >= 1.0 && < 1.1
The default scaffolding works fine, which is created through yesod init.
The version information
yesod-core: 1.0.1
cabal-dev: 0.9.1 (build with Cabal 1.14.0)
cabal-install: 0.10.2
GHC: 7.0.4
OS: Mac OS X Lion
Thanks.
This looks like an overly restrictive upper bound in the authenticate-oauth package. It would be best to follow up directly with the maintainer of that package.
In general, these kinds of issues are a side-effect of following the Package Versioning Policy. Basically, it's a trade-off between having these "refuse to compile" annoyances and more insidious "can't compile" problems.
I don't remember for sure, but I think my change to the cabal file for yesod-auth-oauth fixes this.

Resources