Ticket #649 (closed enhancement: fixed)

Opened 3 years ago

Last modified 14 months ago

better warning messages for why dependencies are missing / cannot be selected

Reported by: duncan Owned by: kosmikus
Priority: normal Milestone: cabal-install-0.14
Component: cabal-install tool Version: HEAD
Severity: normal Keywords: solver
Cc: Difficulty: unknown
GHC Version: Platform:

Description

The cabal-install constraint solver should be given all packages but if some are unsable (e.g. due to broken dependencies) then it should be given constraints to avoid them. That way when it finds it needed the broken package it can give a suitable error message.

Consider the following (real) confusing scenario:

  • usual core global packages
  • mtl as user package
  • gtk etc in a local package db

ghc-pkg list --global -f local gtk reports that gtk is installed and deps are ok.

cabal install --global --package-db=local hsclock reports

cabal: cannot configure hsclock-1.0. It requires cairo -any and gtk -any
There is no available version of cairo that satisfies -any
There is no available version of gtk that satisfies -any

How can this be? It is because when we use --global and --package-db then we are excluding the user package db. But gtk depends on mtl from the user package db. Hence Cabal detects gtk as broken. We did not notice because ghc-pkg --global still includes the --user package db. If we use ghc-pkg --global --no-user-package-conf -f local list then indeed gtk etc are reported as broken.

The point is, cabal should tell us not that gtk isn't installed, but that it was excluded because it is broken, missing dependencies.

Change History

Changed 3 years ago by duncan

Similarly, for installed constraints we should explain in error messages that an installed version is required and list any installed versions that were not suitable or were otherwise excluded.

Consider for example:

build-depends: base == 4.1.*

Suppose someone runs cabal install on this when the only available versions of base are 3.0.3 and 4.2.0 (ie using ghc-6.12.x). Currently we will report:

cabal: cannot configure foo-1.0. It requires base ==4.1.*
For the dependency on base ==4.1.* there are these packages: base-4.1.0.0.
However none of them are available.
base-4.1.0.0 was excluded because of the top level dependency base -any

This lists all the non-installed versions that satisfy the version constraint and tells us (badly) that they're no good because they're not installed. Instead in this situation it's probably better to say it needs an installed version and list the (hopefully) small number of installed versions, even if they do not satisfy the version constraint.

Changed 15 months ago by kosmikus

  • milestone set to cabal-install-0.14

The error messages of the modular solver should hopefully be better. But these are good examples, I should verify.

Changed 15 months ago by kosmikus

  • keywords solver added

Changed 14 months ago by kosmikus

  • owner set to kosmikus

Changed 14 months ago by kosmikus

  • status changed from new to closed
  • resolution set to fixed

Here's the error message the modular solver reports in a similar situation. I added a number of flags to prevent other solutions from being found:

$ cabal install --global --package-db=local aeson-0.6.0.2 --constraint="unordered-containers installed" --dry-run
cabal: Could not resolve dependencies:
trying: aeson-0.6.0.2 (user goal)
next goal: unordered-containers (dependency of aeson-0.6.0.2)
rejecting: unordered-containers-0.2.1.0/installed-171... (package is broken)
rejecting: unordered-containers-0.2.1.0, 0.2.0.1, 0.2.0.0, 0.1.4.6, 0.1.4.5,
0.1.4.4, 0.1.4.3, 0.1.4.2, 0.1.4.1, 0.1.4.0, 0.1.3.0, 0.1.2.0, 0.1.1.0,
0.1.0.0 (global constraint requires installed instance)

The unordered-containers-0.2.1.0 version is installed in the local package DB, but depends on hashable which is installed in the user DB.

If we add the --user flag, it works:

$ cabal install --global --user --package-db=local aeson-0.6.0.2 --constraint="unordered-containers installed" --dry-run
Resolving dependencies...
In order, the following would be installed (use -v for more details):
blaze-builder-0.3.1.0
primitive-0.4.1
vector-0.9.1
aeson-0.6.0.2

The error message for the installed constraint is implicitly shown above as well. Here's another example:

$ ~/.cabal/bin/cabal install repa-3.1.0.1 --dry-run
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: repa-3.1.0.1 (user goal)
next goal: base (dependency of repa-3.1.0.1)
rejecting: base-3.0.3.2, 3.0.3.1 (global constraint requires installed
instance)
rejecting: base-4.3.1.0/installed-20f... (conflict: repa => base==4.5.*)
rejecting: base-4.5.0.0, 4.4.1.0, 4.4.0.0, 4.3.1.0, 4.3.0.0, 4.2.0.2, 4.2.0.1,
4.2.0.0, 4.1.0.0, 4.0.0.0 (global constraint requires installed instance)

This still lists all versions of base, but lists very clearly that we can't use any version but 4.3.1.0 because they're not installed, and we can't use 4.3.1.0 because repa requires 4.5.

Closing this bug.

Note: See TracTickets for help on using tickets.