Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show the import path when reporting solver rejections from project constraints? #9562

Closed
philderbeast opened this issue Dec 25, 2023 · 3 comments · Fixed by #9578
Closed

Comments

@philderbeast
Copy link
Collaborator

Could we show the import path when reporting solver rejections from project constraints?

Here's a mockup example using ascii +-- as the leader instead of the └── leader of the tree command output:

# cabal v2-update
Downloading the latest package list from test-local-repo
# 3-web-dot-relative.project --version-win not supplied, default
# cabal v2-build
Resolving dependencies...
Error: [Cabal-7107]
Could not resolve dependencies:
[__0] trying: cabal-version-override-0.1.0.0 (user goal)
[__1] next goal: hashable (dependency of cabal-version-override)
[__1] rejecting: hashable-1.4.3.0 (constraint from project requires ==1.4.2.0)
     +-- <ROOT>/3-web-dot-relative.project requires ==1.4.2.0
[__1] rejecting: hashable-1.4.2.0 (constraint from project requires ==1.4.3.0)
     +-- <ROOT>/3-web-dot-relative.project
      +-- ./dot-1/hop-web.config
       +-- ./stackage-web.config
        +-- https://www.stackage.org/nightly-2023-12-07/cabal.config requires ==1.4.3.0
[__1] fail (backjumping, conflict set: cabal-version-override, hashable)
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: hashable (3), cabal-version-override (2)

I'd tried using └── leader but it doesn't render properly. The output could be moved further left if desired but I didn't want to interrupt the flow of the [__n] step indicators.

What we show now:

# cabal v2-update
Downloading the latest package list from test-local-repo
# 3-web-dot-relative.project --version-win not supplied, default
# cabal v2-build
Resolving dependencies...
Error: cabal: Could not resolve dependencies:
[__0] trying: cabal-version-override-0.1.0.0 (user goal)
[__1] next goal: hashable (dependency of cabal-version-override)
[__1] rejecting: hashable-1.4.3.0 (constraint from project config <ROOT>/3-web-dot-relative.project requires ==1.4.2.0)
[__1] rejecting: hashable-1.4.2.0 (constraint from project config https://www.stackage.org/nightly-2023-12-07/cabal.config requires ==1.4.3.0)
[__1] fail (backjumping, conflict set: cabal-version-override, hashable)
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: hashable (3), cabal-version-override (2)

To generate the above, I ran the following with a test project I have in the works for #9510.

$ cabal run cabal-testsuite:cabal-tests -- --with-cabal=./dist-newstyle/build/x86_64-linux/ghc-9.4.7/cabal-install-3.11.0.0/x/cabal/build/cabal/cabal cabal-testsuite/PackageTests/VersionPriority/3-web.test.hs --accept
$ cabal run cabal-testsuite:cabal-tests -- --with-cabal=/home/philderbeast/.ghcup/bin/cabal cabal-testsuite/PackageTests/VersionPriority/3-web.test.hs --accept
@9999years
Copy link
Collaborator

9999years commented Oct 28, 2024

Hello, cabal build warp-quic is failing in yesodweb/wai@23b8c4c with an unintuitive failure message on Cabal HEAD:

rejecting: memory-0.18.0 (constraint from user target requires ==0.17.0)

Here, memory-0.17.0 comes from a source-repository-package in the cabal.project.

When I run cabal build warp-quic -v3, here's what it says about the constraints:

constraints:
  any.base installed (non-reinstallable package)
  any.ghc-bignum installed (non-reinstallable package)
  any.ghc-internal installed (non-reinstallable package)
  any.ghc-prim installed (non-reinstallable package)
  any.ghc installed (non-reinstallable package)
  any.integer-gmp installed (non-reinstallable package)
  any.integer-simple installed (non-reinstallable package)
  any.template-haskell installed (non-reinstallable package)
  setup.Cabal >=3.12 (minimum version of Cabal used by Setup.hs)
  setup.Cabal <3.14 (maximum version of Cabal used by Setup.hs)
  auto-update.auto-update ==0.2.1 (user target)
  mime-types.mime-types ==0.1.2.0 (user target)
  recv.recv ==0.1.0 (user target)
  wai.wai ==3.2.4 (user target)
  wai-extra.wai-extra ==3.1.15 (user target)
  warp.warp ==3.4.3 (user target)
  warp-tls.warp-tls ==3.4.7 (user target)
  warp-quic.warp-quic ==0.0.1 (user target)
  wai-app-static.wai-app-static ==3.1.9 (user target)
  wai-websockets.wai-websockets ==3.0.1.3 (user target)
  wai-conduit.wai-conduit ==3.0.0.4 (user target)
  time-manager.time-manager ==0.1.0 (user target)
  foundation.foundation ==0.0.28 (user target)
  basement.basement ==0.0.14 (user target)
  memory.memory ==0.17.0 (user target)

(In my mind, warp-quic is the only real user target here, and the rest are a mix, e.g. memory is from cabal.project, wai is a dependency of warp-quic, auto-update is a transitive dependency (via warp), etc.)

My current hypothesis is that your PR (#9578) does the correct thing, but that something in Cabal is causing these dependencies to be added as "user target" constraints rather than cabal.project constraints. I've poked around the codebase but I can't find where it's going wrong.

@9999years
Copy link
Collaborator

Update: It seems that this error comes from Cabal attempting to resolve the packages in the workspace, before it attempts to figure out what you actually want built.

@grayjay
Copy link
Collaborator

grayjay commented Nov 1, 2024

@9999years Could you please open a new issue for the problem with user target constraints? The fix for this issue only added more information to project config constraints, so I wouldn't expect it to have any effect on whether constraints are labeled as "project config" or "user target". It would also help to see the part of cabal.project that could be adding these packages as targets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants