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

source-repository-package versions show up as user target in error messages #10519

Open
9999years opened this issue Nov 4, 2024 · 2 comments
Assignees
Labels
cabal-install: solver needs triage re: error-message Concerning error messages delivered to the user type: bug

Comments

@9999years
Copy link
Collaborator

Describe the bug

When I do cabal build, a dependency solver error message says:

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

But when I look in the project, no constraint for memory mentions ==0.17.0.

To Reproduce

In yesodweb/wai@b6bc2b6:

$ cabal build warp-quic
Resolving dependencies...
Error: [Cabal-7107]
Could not resolve dependencies:
[__0] next goal: memory (user goal)
[__0] rejecting: memory-0.18.0 (constraint from user target requires ==0.17.0)
[__0] trying: memory-0.17.0
[__1] trying: warp-quic-0.0.1 (user goal)
[__2] next goal: quic (dependency of warp-quic)
[__2] rejecting: quic-0.2.2 (conflict: memory==0.17.0, quic => memory>=0.18.0 && <0.19)
[__2] skipping: quic; 0.2.1, 0.2.0, 0.1.28, 0.1.27, 0.1.26, 0.1.24, 0.1.22, 0.1.21, 0.1.20, 0.1.19, 0.1.18, 0.1.17, 0.1.16, 0.1.15, 0.1.14, 0.1.13, 0.1.12, 0.1.11, 0.1.10 (has the same characteristics that caused the previous version to fail: excludes 'memory' version 0.17.0)
[__2] rejecting: quic-0.1.9 (conflict: warp-quic => quic>=0.2 && <0.3)
[__2] skipping: quic; 0.1.8, 0.1.7, 0.1.6, 0.1.5, 0.1.4, 0.1.3, 0.1.2, 0.1.1, 0.1.0, 0.0.1, 0.0.0, 0.1.25, 0.1.23 (has the same characteristics that caused the previous version to fail: excluded by constraint '>=0.2 && <0.3' from 'warp-quic')
[__2] fail (backjumping, conflict set: memory, quic, warp-quic)
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: quic, memory, warp-quic

Expected behavior

Cabal should say something like:

rejecting: memory-0.18.0 (constraint from source-repository-package in cabal.project requires ==0.17.0)

System information

Operating system: macOS 15.1 (24B83)

$ cabal --version
cabal-install version 3.12.1.0
compiled using version 3.12.1.0 of the Cabal library
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.10.1

Additional context

Related: #9562

@9999years 9999years added type: bug needs triage cabal-install: solver re: error-message Concerning error messages delivered to the user labels Nov 4, 2024
@9999years
Copy link
Collaborator Author

9999years commented Nov 4, 2024

Some notes from my investigation:

The error happens before Cabal resolves cli arguments etc. into actual build
targets; it's just trying to resolve all the local packages, regardless of if
they're involved in your build or not.

Implementation strategy:

  • Propagate provenance (ProjectConfigPath/ConstraintSource) into project config types (Distribution.Client.ProjectConfig, D.C.ProjectConfig.Legacy)

  • Extract and attach that information in D.C.ProjectConfig.findProjectPackages

  • Attach that information to ProjectPackageLocation (returned from findProjectPackages). Note: Might be worth unifying that with PackageLocation, would make the new type PackageLocationProvenance.

  • Use that information to write better ConstraintSources into the solver; this is mostly implemented.

Overall it seems like all the information exists, but it takes a lot of work to propagate it into the right parts of the system. Expect a ~hundreds of lines diff.

@philderbeast
Copy link
Collaborator

I can reproduce this on ubuntu linux. The error message is not very helpful but the title of this issue "source-repository-package versions show up as user target" is.

I can get warp-quic built by adding allow-older to the project but this may not be a good build because of the version constraint exceptions.

$ cabal build warp-quic --dry-run
Resolving dependencies...
Build profile: -w ghc-9.10.1 -O1
In order, the following would be built (use -v for more details):
 - auto-update-0.2.2 (lib) (first run)
 - basement-0.0.14 (lib) (requires build)
 - cereal-0.5.8.3 (lib) (requires build)
 - half-0.3.1 (lib) (requires build)
 - http-types-0.12.4 (lib) (requires build)
 - iproute-1.7.15 (lib) (requires download & build)
 - psqueues-0.2.8.0 (lib) (requires build)
 - recv-0.1.0 (lib) (first run)
 - simple-sendfile-0.2.32 (lib) (requires build)
 - sockaddr-0.0.1 (lib) (requires download & build)
 - streaming-commons-0.2.2.6 (lib) (requires build)
 - unix-compat-0.7.3 (lib) (requires download & build)
 - unix-time-0.4.16 (lib:unix-time) (requires download & build)
 - unliftio-0.2.25.0 (lib) (requires build)
 - vault-0.3.1.5 (lib) (requires build)
 - memory-0.17.0 (lib) (requires build)
 - cborg-0.2.10.0 (lib) (requires build)
 - network-control-0.1.3 (lib) (requires build)
 - fast-logger-3.2.5 (lib) (requires download & build)
 - time-manager-0.1.0 (lib) (first run)
 - wai-3.2.4 (lib) (first run)
 - pem-0.2.4 (lib) (requires build)
 - crypton-1.0.1 (lib) (requires download & build)
 - asn1-types-0.3.4 (lib:asn1-types) (requires build)
 - serialise-0.2.6.1 (lib) (requires build)
 - http-semantics-0.2.1 (lib) (requires build)
 - crypto-token-0.1.2 (lib) (requires download & build)
 - asn1-encoding-0.9.6 (lib) (requires build)
 - http2-5.3.4 (lib) (requires build)
 - asn1-parse-0.9.5 (lib:asn1-parse) (requires build)
 - crypton-x509-1.7.7 (lib) (requires build)
 - warp-3.4.3 (lib) (first run)
 - crypton-x509-store-1.6.9 (lib) (requires build)
 - crypton-x509-validation-1.6.12 (lib) (requires build)
 - crypton-x509-system-1.6.7 (lib) (requires build)
 - tls-2.1.3 (lib) (requires download & build)
 - quic-0.2.3 (lib) (requires download & build)
 - http3-0.0.18 (lib) (requires download & build)
 - warp-quic-0.0.1 (lib) (first run)

$ git diff
diff --git a/cabal.project b/cabal.project
index d04fec5a..c3069acf 100644
--- a/cabal.project
+++ b/cabal.project
@@ -48,6 +48,10 @@ allow-newer:
     , hsc2hs:base
     , cabal-doctest:base
 
+allow-older:
+    , *:memory
+    , *:basement
+
 -- https://github.com/haskell-foundation/foundation/pull/564
 source-repository-package
     type: git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cabal-install: solver needs triage re: error-message Concerning error messages delivered to the user type: bug
Projects
None yet
Development

No branches or pull requests

4 participants