Dependency conflicts of base in Haskell cabal - haskell

There comes up with a problem that cabal's base is conflicted with the dependency in .cabal file, it seems that my base version is too high, so is there a way to downgrade my base package version in the cabal sandbox.
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: decafc-0.0.0 (user goal)
[__1] next goal: base (dependency of decafc)
[__1] rejecting: base-4.11.1.0/installed-4.1... (conflict: decafc => base>=4.5
&& <=4.9)
[__1] rejecting: 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, decafc)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base, decafc
Note: when using a sandbox, all packages are required to have consistent
dependencies. Try reinstalling/unrstering the offending packages or
recreating the sandbox.
There is another problem that when using stack, how to add some flags to the alex if running stack build, for example, the cabal instruction is cabal install --alex-options="--ghc --template=\"$TOP/alex\"". So how to let the stack do the same things?

The base dependency indicates that it only works with versions between 4.5 and 4.9. That means the latest GHC you can use this package with is 8.0.1, since base ships with GHC and can't be upgraded. You could bump the dependency yourself, but you would likely have to fix things that don't work anymore due to changes in base, or you could install an older version of GHC.

Related

How to let `cabal install` ignore the local `.cabal` file?

Versions
%cabal --version
cabal-install version 3.6.2.0
compiled using version 3.6.2.0 of the Cabal library
%ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.10.7
Problem
I want to install weeder. If there is no *.cabal file in the current directory, running cabal install weeder succeeds. However, if the one exists and contains a dependency that conflicts with what weeder requires, cabal install weeder fails.
For example, if a .cabal file contains text < 1.2.3.0 as build-depends, cabal install weeder fails with the message below:
%cabal install weeder
cabal: Could not resolve dependencies:
[__0] trying: foobarbaz-0.1.0.0 (user goal)
[__1] next goal: text (dependency of foobarbaz)
[__1] rejecting: text-1.2.4.1/installed-1.2.4.1 (conflict: foobarbaz =>
text<1.2.3.0)
[__1] skipping: text-1.2.5.0, text-1.2.4.1, text-1.2.4.0, text-1.2.3.2,
text-1.2.3.1, text-1.2.3.0 (has the same characteristics that caused the
previous version to fail: excluded by constraint '<1.2.3.0' from 'foobarbaz')
[__1] trying: text-1.2.2.2
[__2] next goal: deepseq (dependency of text)
[__2] rejecting: deepseq-1.4.4.0/installed-1.4.4.0 (conflict: text =>
base>=4.2 && <4.11, deepseq => base==4.14.3.0/installed-4.14.3.0)
[__2] trying: deepseq-1.4.5.0
[__3] next goal: array (dependency of text)
[__3] rejecting: array-0.5.4.0/installed-0.5.4.0 (conflict: text => base>=4.2
&& <4.11, array => base==4.14.3.0/installed-4.14.3.0)
[__3] trying: array-0.5.4.0
[__4] next goal: base (dependency of foobarbaz)
[__4] rejecting: base-4.14.3.0/installed-4.14.3.0 (conflict: text => base>=4.2
&& <4.11)
[__4] skipping: base-4.16.0.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 (has the same characteristics that caused the previous version
to fail: excluded by constraint '>=4.2 && <4.11' from 'text')
[__4] rejecting: 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)
[__4] fail (backjumping, conflict set: base, foobarbaz, text)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base, text, deepseq, array, foobarbaz
Try running with --minimize-conflict-set to improve the error message.
I can avoid this by mv foobarbaz.cabal foobarbaz.cabal.bk before cabal install weeder and mv foobarbaz.cabal.bk foobarbaz.cabal after the install, or running cabal install weeder in the other directory. But is there an option to ignore the local .cabal file?
Cabal has a --project-file option. It turns out that when specified empty, this causes cabal-install to not use any project file, even when one is in the current directory.
cabal v2-install --project-file="" weeder
After I posted the question, I found that the -z and --ignore-project options are also what I wanted.
cabal install -z weeder

Could not resolve dependencies while installing libraries with cabal

Every effort of me trying to install a library using cabal on Window 10 resulted in the same error:
cabal install gtk
cabal.exe: Could not resolve dependencies:
[__0] trying: parconc-examples-0.4.8 (user goal)
[__1] next goal: base (dependency of parconc-examples)
[__1] rejecting: base-4.15.0.0/installed-4.15.0.0 (conflict: parconc-examples
=> base>=4.5 && <4.14)
[__1] skipping: base-4.15.0.0, base-4.14.2.0, base-4.14.1.0, base-4.14.0.0
(has the same characteristics that caused the previous version to fail:
excluded by constraint '>=4.5 && <4.14' from 'parconc-examples')
[__1] rejecting: 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, parconc-examples)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base, parconc-examples
It worked perfectly fine on Linux, but I have not found how to resolve the problem on Windows.
Your version of the base library is 4.15.0.0. base is special in the sense that its version is tied to your GHC version, which seems to be GHC 9.0.1.
So, unlike with other libraries, cabal can't simply install a previous version of base when it's required by the build-depends: of some package.
parconc-examples has the following constraint on base: >=4.5 && <4.14. So version 4.15 is not accepted ("constraint from non-upgradeable package requires installed instance").
One thing you could try is to pass the extra option --allow-newer=base, like cabal install --allow-newer=base gtk. This will relax the restriction.
But it isn't a panacea: parconc-examples (or other package required by gtk) might actually fail to build with base == 4.15, because it might use some aspect of base == 4.14 that has changed in a non-backwards compatible way. Preventing such build failures is the purpose of bounds, after all.

I am getting this error when trying to install Cardano-Node

cabal: Could not resolve dependencies:
[__0] trying: Win32-network-0.1.0.0 (user goal)
[__1] next goal: base (dependency of Win32-network)
[__1] rejecting: base-4.14.1.0/installed-4.14.1.0 (conflict: Win32-network =>
base>=4.5 && <4.13)
[__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: Win32-network, base)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base, Win32-network
I am doing cabal install cardano-node cardano-cli within my Linux/Ubuntu environment.
Looks like this commit relaxes that constraint suitably. Looks like the master branch of the cardano-node repo already requests a commit later than that, so probably just updating that repo will get you where you need to go.
Install cardano-cli & cardano-node the easy way on Mac:
Download the daedaluswallet.io wallet and install.
nano ~/.zshrc
export PATH=$PATH:/Applications/Daedalus\ Mainnet.app/Contents/MacOS
source ~/.zshrc

Cabal can't install ghc-mod

I'm trying to install ghc-mod to use with Atom-Haskell (the ide-haskell package) in Atom, but for some reason my Cabal doesn't want to.
When I enter the command cabal install ghc-mod, I get the following errors in my terminal:
Resolving dependencies...
cabal.exe: Could not resolve dependencies:
[__0] trying: ghc-mod-5.8.0.0 (user goal)
[__1] trying: syb-0.7.1 (dependency of ghc-mod)
[__2] next goal: base (dependency of ghc-mod)
[__2] rejecting: base-4.14.1.0/installed-4.14.1.0 (conflict: ghc-mod =>
base<4.10 && >=4.6.0.1)
[__2] skipping: 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 (has the same characteristics that
caused the previous version to fail: excluded by constraint '<4.10 &&
>=4.6.0.1' from 'ghc-mod')
[__2] rejecting: 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)
[__2] fail (backjumping, conflict set: base, ghc-mod)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base, ghc-mod, syb
I installed Cabal as part of the Haskell Platform, so to my understanding, it's a bit unusually configured. I don't have a %HOME%.cabal folder, and I don't know if that could be part of the issue?
I don't know a lot about how Cabal or ghc-mod work, so please let me know if you need any more info!
Thanks for any help!
You probably have a new version of base, (https://wiki.haskell.org/Base_package) where ghc-mod is only compatible with versions >=4.6.0.1 && <4.10 (https://hackage.haskell.org/package/ghc-mod). You'd have to downgrade.

Why can I not install haskell Slides package?

Attempting to install Haskell's Slides package, I run into cabal hell:
$ cabal update && cabal install slides
Downloading the latest package list from hackage.haskell.org
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: Slides-0.1.0.8 (user goal)
next goal: base (dependency of Slides-0.1.0.8)
rejecting: base-4.9.0.0/installed-4.9... (conflict: Slides => base>=4.8 &&
<4.9)
rejecting: 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)
Dependency tree exhaustively searched.
I reset my packages by running:
$ rm -rf ~/.ghc ~/.cabal
per the instructions here, but still get that same error. Not sure what to try next.
Slides library 0.1.0.8 (https://hackage.haskell.org/package/Slides) has not been updated to work with GHC versions > 7.10. This is apparent from the base restriction base < 4.9 since GHC 8 uses base 4.9.
You can:
File an issue with the maintainer, who should fix this and upload a new version.
cabal unpack slides then cd slides* and edit slides.cabal changing < 4.9 to < 4.10 then cabal install. That is usually all that is required, but not always so you might see a new set of compilation errors.

Resources