What can cause `stack build` to keep unregistering local dependencies every time? - haskell

I've tried stack clean, and also removing .stack-work.
But still, every time I run build it unregisters 5 (the same) packages.
stack build --dry-run tells me the list, but not any reason why.
I've also recently upgraded from 1.4.1
Also, if it is not quite simple how to figure this out, I'd like to get back to using 1.4.1. Any simple way to downgrade haskell-stack to that version?
Edit 1
Downgrading to 1.4.0 didn't help. About 70 packages got unregistered and rebuilt, and after that I got into the same 5-unregister-loop.
So I thought, where else could have my local state be corrupted since ~yesterday? ~/.stack! So I've (re)moved my ~/.stack folder, and also .stack-work folder, thinking that if anything could have gone wrong it's in these two places, and now I am in an even worse of a rut. Now the constant unregister cycle includes 23 packages (some of them quite heavy) instead of just 5.
Would unregister locally:
cairo-0.13.3.1 (missing dependencies: gtk2hs-buildtools)
dump-0.3.0 (missing dependencies: haskell-src-meta, interpolatedstring-perl6)
entropy-0.3.7
ghcjs-dom-0.2.4.0 (missing dependencies: glib, gtk3, webkitgtk3)
gio-0.13.3.1 (missing dependencies: glib, gtk2hs-buildtools)
glib-0.13.4.1 (missing dependencies: gtk2hs-buildtools)
gtk2hs-buildtools-0.13.2.2 (missing dependencies: happy)
gtk3-0.14.6 (missing dependencies: cairo, gio, glib, gtk2hs-buildtools, pango)
haskell-src-exts-1.17.1 (missing dependencies: happy)
haskell-src-meta-0.6.0.14 (missing dependencies: haskell-src-exts)
here-1.2.9 (missing dependencies: haskell-src-meta)
hs-di-0.4.0 (missing dependencies: haskell-src-meta, interpolate, interpolatedstring-perl6)
interpolate-0.1.0 (missing dependencies: haskell-src-meta)
interpolatedstring-perl6-1.0.0 (missing dependencies: haskell-src-meta)
pango-0.13.3.1 (missing dependencies: cairo, glib, gtk2hs-buildtools)
reflex-0.5.0 (missing dependencies: haskell-src-exts, haskell-src-meta)
reflex-dom-0.4 (missing dependencies: ghcjs-dom, glib, gtk3, reflex, webkitgtk3, webkitgtk3-javascriptcore)
threepenny-gui-0.7.1.0
uuid-1.3.13
webkitgtk3-0.14.2.1 (missing dependencies: cairo, glib, gtk2hs-buildtools, gtk3, pango)
webkitgtk3-javascriptcore-0.13.2.0 (missing dependencies: glib, gtk2hs-buildtools, gtk3, webkitgtk3)
websockets-0.9.8.2
websockets-snap-0.10.0.0
#user2407038, what kind of information might help to start diagnosing this? Is the above helpful to begin with? Under what circumstances can ever such an unregister-loop arise?
I have one more idea that I could try: this particular project depends on a few local packages, and afaik their .stack-work folder may play a role in this. So maybe I could (re)move those as well.
Any more ideas should the above one fail?

Long story short: changing resolver: lts-7.19 to resolver: lts-7.24 in stack.yaml seems to have fixed the error for me.
I have some guesses and hunches what may have gone wrong in the background, but I am not entirely sure.
I got a clue from the --dry-run flag that some of the missing packages it reports are build-time haskell package dependencies, like alex, happy, etc...
So maybe the older lts didn't install those correctly? If someone is more knowledgeable on the subject, I'd love to hear more.
And I'm also sad that this incident has destroyed some of my trust in stack's promise of reproducible builds, as a (AFAIK purported-to-be-safe) stack upgrade (and even with subsequent downgrade) suddenly left one of my projects un-buildable for days.
And at any rate, I'd love if
stack would warn and ask me before it makes destructive changes on my system, especially if it results in hours of recompilation. (Which actually meant days of head-scratching in my case since any idea I tried I had to wait quite a bit of time in-between.)
It could employ a similar build store as nix, whereas even if I change some configuration, I can switch back to the previous working configuration readily.

As a partial solution, I found that I can
stack upgrade --binary-version 1.4.0
Which readily performs the downgrade:
Current Stack version: 1.5.1, available download version: 1.4.0
Forcing binary upgrade
Querying for archive location for platform: linux-x86_64-static
Downloading from: https://github.com/commercialhaskell/stack/releases/download/v1.4.0/stack
-1.4.0-linux-x86_64-static.tar.gz
Download complete, testing executable
Version 1.4.0, Git revision e714f1dd3fade19496d91bd6a017e435a96a6bcd (4640 commits) x86_64
hpack-0.17.0
New stack executable available at /home/user/.local/bin/stack

It could have been the case the you were hitting this bug: Better calculation of SourceMap, but again not enough information to tell for sure. Considering that this issue will get fixed soon, it shouldn't be a problem anymore, but if anyone is looking for a work around custom snapshots seem to work pretty well.
The gist of custom snapshots is by moving all immutable packages from extra-deps into a custom snapshot will prevent stack from recalculating dependencies for these packages.

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.

Haskell dependency hell

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

Haskell on Travis CI fails, passes locally

https://travis-ci.org/Fresheyeball/fbatch
Preprocessing library monad-parallel-0.5...
Control/Monad/Parallel.hs:67:8:
Could not find module `Control.Monad.Identity'
It is a member of the hidden package `mtl-2.2.1'.
Perhaps you need to add `mtl' to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
cabal: Error: some packages failed to install:
monad-parallel-0.5 failed during the building phase. The exception was:
ExitFailure 1
I am new to haskell, and just can't seem to get past this. I've tinkered with my .cabal file all I can, and the sub dependency fails on Travis every time.
Please help.
If a build fails while resolving a dependency, it's worth having a look a what version of that package gets installed. Normally, cabal should default to the most recent possible, which if well-maintained should install fine. Older versions do of course often mean trouble, if some dependency of theirs has now a newer, incompatible version installed.
In your case, cabal tried to install the somewhat ancient monad-parallel-0.5, which imports a module that doesn't exist in transformers (namely Control.Monad.Identity). The more recent version 0.7.1.2 does not try this and thus builds successfully. You can force such a recent install by giving a lower bound to the dependency in your .cabal file, in this case monad-parallel >= 0.7.

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.

Cannot install Yorgey et al's "unbound" library with latest GHC/Haskell Platform

Has anybody managed to get Yorgey et al's "unbound" library, for working with syntax with binding, to install with the latest GHC (7.0.3) and Haskell platform? Trying a cabal install unbound, I get the following:
Resolving dependencies...
cabal: cannot configure unbound-0.2.3. It requires base >=4.3 && <5
For the dependency on base >=4.3 && <5 there are these packages: base-4.3.0.0
and base-4.3.1.0. However none of them are available.
base-4.3.0.0 was excluded because of the top level dependency base -any
base-4.3.1.0 was excluded because of the top level dependency base -any
Anybody know a solution/work around, or what may be happening here?
Just to close this one:
The "unbound" library works fine with the 2011 Haskell Platform, and indeed, builds without warnings.
The OP had multiple (older) versions of GHC in his path, leading to build errors, since the package relies on GHC 7. Ensuring you have exactly the Haskell Platform environment is the solution.
As a note, we should write a script that checks the sanity of a given Haskell environment, to catch errors like this.

Resources