How to fail fast(er) when trying to update a package in Haskell? - haskell

Problem
In a very used library
haddock we have
#if MIN_VERSION_ghc(9,2,0) && !MIN_VERSION_ghc(9,3,0)
Those hidden dependencies make it into the built binary.
So, say, haddocset builds just fine thanks to stack.yaml targeting lts-12.0, with extra-dependency
extra-deps:
- haddock-api-2.20.0
- haddock-library-1.6.0
And then when running the actual executable
haddock: internal error: /Users/nicolas/.stack/programs/x86_64-osx/ghc-8.4.4/lib/ghc-8.4.4/settings: openFile: does not exist (No such file or directory)
Updating with Stackage
To update haddocset to lts-18.25 as far as I understand I have to update the "extra-deps" which entails to
check GHC version (in my case from LTS-18.25 so ghc 8.10.7).
check which version of the base library 8.10.7 comes with in the release notes so 4.14.3.0
browse through hackage to find which version of that package has a compatible base library so its haddock-api-2.24.0
same for finding hsdev-0.3.1.4 hdocs-0.4.4.1
then stack build suggests to add
- MonadCatchIO-transformers-0.3.1.3#sha256:468a6f12fd3821d2ab6301cc3543930c05e5117118917c6857ea383bdcc96c54,1127
- ghc-syb-utils-0.2.3.3#sha256:fc4cd944bbd4d5160b2ee8bb458974a135c0abbd9941fb6e5f9180164efd091a,1302
which look compatible on hackage.
Then I get an error from ghc-syb-utils
ghc-syb-utils > /private/var/folders/nw/tfpqw8w97hq8kw7kvf1qst2w0000gn/T/stack-03a7d85958fa8f57/ghc-syb-utils-0.2.3.3/GHC/SYB/Utils.hs:258:64: error:
ghc-syb-utils > • Could not deduce (Outputable (HsOverLit RdrName))
which says something on ghc-syb-utils (ghc (>=7.10 && <8.6)) and something else on github ("GHC 8.0 or later is not supported")
So I can't build this binary for 8.10.7/LTS-18.25.
Updating with Cabal
I am no expert at all on cabal, because having random build plan depending on what is currently published is both totally mad for end-users, and a great freedom for library authors who want their updates to be picked up everywhere silently. And I am just a user here, wanting to install a binary.
Of course the project haddocset as it is does not build with cabal anymore, although nothing has changed, because (I think) of the said madness, either with v1-build or v2-build prayer. Maybe some way do exist. I just don't know.
If in the cabal file one set the bounds for base and ghc, relax the upper bounds for the other dependencies, or else, there are only the usual message about "backjumping" from those invocation
🕙[ 04:42:14 ] [💣 1] ❯ cabal-3.4.1.0 v1-build
Resolving dependencies...
Warning: solver failed to find a solution:
Could not resolve dependencies:
[__0] trying: haddocset-0.4.3 (user goal)
[__1] next goal: base (dependency of haddocset)
[__1] rejecting: base-4.12.0.0/installed-4.12.0.0 (conflict: haddocset =>
base>=4.14.3.0 && <5)
[__1] fail (backjumping, conflict set: base, haddocset)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: haddocset, base
Trying configure anyway.
Configuring haddocset-0.4.3...
cabal-3.4.1.0: Encountered missing or private dependencies:
base >=4.14.3.0 && <5,
conduit,
conduit-extra,
haddock-api >=2.15,
hsdev,
http-types,
resourcet,
sqlite-simple
🕙[ 04:42:11 ] [💣 130] ❯ cabal-3.4.1.0 v2-build
Resolving dependencies...
cabal-3.4.1.0: Could not resolve dependencies:
[__0] trying: haddocset-0.4.3 (user goal)
[__1] next goal: base (dependency of haddocset)
[__1] rejecting: base-4.12.0.0/installed-4.12.0.0 (conflict: haddocset =>
base>=4.14.3.0 && <5)
[__1] rejecting: base-4.16.0.0, base-4.15.1.0, base-4.15.0.0, base-4.14.3.0,
base-4.14.2.0, base-4.14.1.0, base-4.14.0.0, base-4.13.0.0, base-4.12.0.0,
base-4.11.1.0, base-4.11.0.0, base-4.10.1.0, base-4.10.0.0, base-4.9.1.0,
base-4.9.0.0, base-4.8.2.0, base-4.8.1.0, base-4.8.0.0, base-4.7.0.2,
base-4.7.0.1, base-4.7.0.0, base-4.6.0.1, base-4.6.0.0, base-4.5.1.0,
base-4.5.0.0, base-4.4.1.0, base-4.4.0.0, base-4.3.1.0, base-4.3.0.0,
base-4.2.0.2, base-4.2.0.1, base-4.2.0.0, base-4.1.0.0, base-4.0.0.0,
base-3.0.3.2, base-3.0.3.1 (constraint from non-upgradeable package requires
installed instance)
[__1] fail (backjumping, conflict set: base, haddocset)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base, haddocset
Question
What are the fastest way, either with stack or with cabal, to spot that there are real code issue in ghc-syb-utils, so that it's not just a matter of updating dependencies ?

Related

How to handle following dependency conflict in Cabal?

When I try to add scotty package to my multi-project cabal file, I get following dependency conflict. I am not exactly sure what it means.
harshal#Harshals-Linux hello-haskell % cabal build
Resolving dependencies...
Error: cabal: Could not resolve dependencies:
[__0] trying: playground-0.1.0.0 (user goal)
[__1] trying: scotty-0.12.1 (dependency of playground)
[__2] trying: warp-3.3.23 (dependency of scotty)
[__3] trying: unix-compat-0.6 (dependency of warp)
[__4] trying: unix-2.7.3/installed-2.7.3 (dependency of warp)
[__5] next goal: directory (dependency of playground)
[__5] rejecting: directory-1.3.7.1/installed-1.3.7.1 (conflict: playground =>
directory>=1.3.8.0)
[__5] rejecting: directory-1.3.8.0 (conflict: unix==2.7.3/installed-2.7.3,
directory => unix>=2.8.0 && <2.9)
[__5] rejecting: directory-1.3.7.1 (conflict: playground =>
directory>=1.3.8.0)
[__5] skipping: directory-1.3.7.0, directory-1.3.6.2, directory-1.3.6.1,
directory-1.3.6.0, directory-1.3.5.0, directory-1.3.4.0, directory-1.3.3.2,
directory-1.3.3.1, directory-1.3.3.0, directory-1.3.2.2, directory-1.3.2.1,
directory-1.3.2.0, directory-1.3.1.5, directory-1.3.1.4, directory-1.3.1.3,
directory-1.3.1.2, directory-1.3.1.1, directory-1.3.1.0, directory-1.3.0.2,
directory-1.3.0.1, directory-1.3.0.0, directory-1.2.7.1, directory-1.2.7.0,
directory-1.2.6.3, directory-1.2.6.2, directory-1.2.5.1, directory-1.2.5.0,
directory-1.2.4.0, directory-1.2.3.1, directory-1.2.3.0, directory-1.2.2.1,
directory-1.2.2.0, directory-1.2.1.0, directory-1.2.0.1, directory-1.2.0.0,
directory-1.1.0.2, directory-1.1.0.1, directory-1.1.0.0, directory-1.0.1.2,
directory-1.0.1.1, directory-1.0.1.0, directory-1.0.0.3, directory-1.0.0.0,
directory-1.2.6.1 (has the same characteristics that caused the previous
version to fail: excluded by constraint '>=1.3.8.0' from 'playground')
[__5] fail (backjumping, conflict set: directory, playground, unix)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: directory, unix, playground,
unix-compat, warp, unix-compat:portable, scotty
Try running with --minimize-conflict-set to improve the error message.
How can I resolve this dependency conflict?
What this says:
playground-0.1.0.0 depends on directory >= 1.3.8.0
directory-1.3.8.0 is the only apparent solution to directory >= 1.3.8.0
directory-1.3.8.0 depends on unix >= 2.8.0 && <2.9
we already committed to unix==2.7.3, which does not satisfy that constraint
One thing you could try, therefore, is to give it a hint that you want to pick a newer unix, by adding a top-level constraint:
% cabal build --constraint `unix >=2.8.0 && <2.9`
Top-level constraints are "available" earlier than constraints found via searching for dependencies, and so can constrain earlier choices better. (I believe this property -- that constraints get solved and committed to in some not-totally-user-visible order -- is to make the dependency resolution algorithm more efficient. Bummer.)

Dificoulties installing gloss and other packages with cabal

I am trying to install gloss but, I dont know why ghci doesn't find the modules.
When I do cabal install gloss it says:
Up to date
Warning: You asked to install executables, but there are no executables in
target: gloss. Perhaps you want to use --lib to install libraries instead.
When I do cabal install -lib gloss it gives me thies error:
Resolving dependencies...
cabal.exe: Could not resolve dependencies:
[__0] trying: bytestring-0.11.0.0 (user goal)
[__1] next goal: directory (user goal)
[__1] rejecting: directory-1.3.6.1 (constraint from user target requires
==1.3.6.0)
[__1] trying: directory-1.3.6.0/installed-1.3.6.0
[__2] next goal: Win32 (dependency of directory)
[__2] rejecting: Win32-2.6.1.0/installed-2.6.1.0 (conflict:
bytestring==0.11.0.0, Win32 => bytestring==0.10.10.0/installed-0.10.10.0)
[__2] rejecting: Win32-2.10.1.0, Win32-2.10.0.0, Win32-2.9.0.0, Win32-2.8.5.0,
Win32-2.8.4.0, Win32-2.8.3.0, Win32-2.8.2.0, Win32-2.8.1.0, Win32-2.8.0.0,
Win32-2.7.0.0, Win32-2.6.2.0, Win32-2.6.1.0, Win32-2.6.0.0, Win32-2.5.4.1,
Win32-2.5.3.0, Win32-2.5.2.0, Win32-2.5.1.0, Win32-2.5.0.0, Win32-2.4.0.0,
Win32-2.3.1.1, Win32-2.3.1.0, Win32-2.3.0.2, Win32-2.3.0.1, Win32-2.3.0.0,
Win32-2.2.2.0, Win32-2.2.1.0, Win32-2.2.0.2, Win32-2.2.0.1, Win32-2.2.0.0,
Win32-2.1.0.0, Win32-2.1, Win32-2.5.4.0 (conflict: directory =>
Win32==2.6.1.0/installed-2.6.1.0)
[__2] fail (backjumping, conflict set: Win32, bytestring, directory)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: ghc, bytestring, Win32, directory
Try running with --minimize-conflict-set to improve the error message.
This is very strange because the firs time I used this command it worked perfectly but then when I tried to do on ghci ´´´import ...´´´ it sayd: Module not found.
I have tried other modules and it gives me the same error. I thought that the issue could be that ghc is not able to search in the cabal folder where the packages are saved but I am no longer sure.
How can I fix this? Thanks

Trouble cabal installing http-conduit

When I run cabal install http-conduit, I get the following:
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: base-4.12.0.0/installed-4.1... (user goal)
[__1] trying: ghc-8.6.5/installed-8.6... (user goal)
[__2] next goal: process (user goal)
[__2] rejecting: process-1.6.7.0 (constraint from user target requires
==1.6.6.0)
[__2] rejecting: process-1.6.6.0 (conflict: ghc =>
process==1.6.5.0/installed-1.6...)
[__2] rejecting: process-1.6.5.1, process-1.6.5.0/installed-1.6...,
process-1.6.5.0, process-1.6.4.0, process-1.6.3.0, process-1.6.2.0,
process-1.6.1.0, process-1.6.0.0, process-1.5.0.0, process-1.4.3.0,
process-1.4.2.0, process-1.4.1.0, process-1.4.0.0, process-1.3.0.0,
process-1.2.3.0, process-1.2.2.0, process-1.2.1.0, process-1.2.0.0,
process-1.1.0.2, process-1.1.0.1, process-1.1.0.0, process-1.0.1.5,
process-1.0.1.4, process-1.0.1.3, process-1.0.1.2, process-1.0.1.1,
process-1.0.0.0 (constraint from user target requires ==1.6.6.0)
[__2] fail (backjumping, conflict set: ghc, process)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: process, base, ghc
I'm running cabal v3.0.0.0 and ghc v8.6.5
I'm quite new to the Haskell ecosystem, so any help I could get would be greatly appreciated. Thanks!
It looks like you have a dependency conflict, one package requires a different version than the package you are trying to install. This can be very difficult to solve for new users.
If you are new to Haskell and want to start using dependencies from Hackage, the centralized package archive for Haskell, I recommend using stack (install instructions and basic workflow. stack is a tool built on top of cabal that includes a curated list of package versions that are compatible. It should make it easier for you to get started.

Cabal Install trouble resolving dependencies

I'm following this tutorial trying to set up a Haskell project: http://shuklan.com/haskell/lec10.html#/0/9
I've had this issue before with 'cabal install'.
I get the message below. I read to try 'rm -rf ~/.ghc ~/.cabal'. I tried that and 'cabal install' again, along with 'cabal new-build' but I still get the same message.
How can I fix this? I'm on Mac OS X 10.11.4. I can make and run .hs files and us ghci. I've never created a "file structure" or anything like that with other programming languages, so I'm not familiar with what's involved.
Thank you!!
Please switch to using either the new project style and the new-install
command or the legacy v1-install alias as new-style projects will become the
default in the next version of cabal-install. Please file a bug if you cannot
replicate a working v1- use case with the new-style commands.
For more information, see: https://wiki.haskell.org/Cabal/NewBuild
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: FirstCabalInit-0.1.0.0 (user goal)
[__1] next goal: base (dependency of FirstCabalInit)
[__1] rejecting: base-4.12.0.0/installed-4.1... (conflict: FirstCabalInit =>
base==4.6.*)
[__1] rejecting: base-4.12.0.0, base-4.11.1.0, base-4.11.0.0, base-4.10.1.0,
base-4.10.0.0, base-4.9.1.0, base-4.9.0.0, base-4.8.2.0, base-4.8.1.0,
base-4.8.0.0, base-4.7.0.2, base-4.7.0.1, base-4.7.0.0, base-4.6.0.1,
base-4.6.0.0, base-4.5.1.0, base-4.5.0.0, base-4.4.1.0, base-4.4.0.0,
base-4.3.1.0, base-4.3.0.0, base-4.2.0.2, base-4.2.0.1, base-4.2.0.0,
base-4.1.0.0, base-4.0.0.0, base-3.0.3.2, base-3.0.3.1 (constraint from
non-upgradeable package requires installed instance)
[__1] fail (backjumping, conflict set: FirstCabalInit, base)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base, FirstCabalInit ```
You can find the following guide to build tools in Haskell useful:
https://kowainik.github.io/posts/2018-06-21-haskell-build-tools
According the error message, it looks like in your .cabal file you have a line like
build-depends: base == 4.6.*
This version of the standard library base is very old, it corresponds to GHC-7.6, however, according to the error message, you have GHC-8.6.5 installed. Since base versions are bundled with GHC, you can't use base for GHC you didn't install. See the following list of matching base and GHC versions:
https://wiki.haskell.org/Base_package
It looks like your error can be resolved by the following fix:
build-depends: base == 4.12.*
For the future, I can recommend using ghcup tool to manage GHC and cabal-install versions on macOS:
https://www.haskell.org/ghcup/
Alternatively, you can use stack build tool, it manages GHC versions for you in a sandboxed location.
Famous "cabal hell".
You're better use newest package manager https://docs.haskellstack.org/en/stable/README/ .

`cabal-install` refuses to solve conflicting `ghc` and `containers` versions

This repository contains a reproduction for an annoying error I got while using doctest in a test-suite.
cabal-installs solver fails to find a solution for this build-depends field using GHC 8.0.2:
build-depends:
base >= 4.7 && < 5
, doctest == 0.11.4
, containers == 0.5.10.2
Note that doctest depends transitively depends on ghc-8.0.2, which itself depends on containers-0.5.7.1, conflicting with my own constraints.
That's basically what cabal install is trying to tell me:
Resolving dependencies...
cabal.exe: Could not resolve dependencies:
next goal: containers (dependency of repro-0.1.0.0)
rejecting: containers-0.5.7.1/installed-0.5... (conflict: repro =>
containers==0.5.10.2)
trying: containers-0.5.10.2
next goal: doctest (dependency of repro-0.1.0.0)
rejecting: doctest-0.13.0, doctest-0.12.0 (conflict: repro => doctest==0.11.4)
trying: doctest-0.11.4
next goal: ghc (dependency of doctest-0.11.4)
rejecting: ghc-8.0.2/installed-8.0... (conflict: containers==0.5.10.2, ghc =>
containers==0.5.7.1/installed-0.5...)
Dependency tree exhaustively searched.
Now, what bugs me is that stack install works just fine using lts-9 and an extra-deps for the containers version.
So in theory, cabal-install could also do 'the right thing' here. How can I tell it to?

Resources