Skip to content

Only consider version constraints with --reject-unconstrained-dependenies - #12191

Open
philderbeast wants to merge 19 commits into
haskell:masterfrom
cabalism:fix/flag-as-version
Open

Only consider version constraints with --reject-unconstrained-dependenies#12191
philderbeast wants to merge 19 commits into
haskell:masterfrom
cabalism:fix/flag-as-version

Conversation

@philderbeast

@philderbeast philderbeast commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Fixes #12190.

I'll squash commits before applying the merge label if this pull request is approved.

Manual QA Notes

Compare running the included package test with the version of cabal-install:exe:cabal from this branch and with a released version, such as cabal-3.16.1.0.

Run the test locally manually, it should pass.

$ ghc --numeric-version
9.14.1

$ cabal build all --enable-tests

$ cabal run cabal-testsuite:cabal-tests -- \
  --with-cabal=./dist-newstyle/build/x86_64-linux/ghc-9.14.1/cabal-install-3.19.0.0/x/cabal/build/cabal/cabal \
  cabal-testsuite/PackageTests/RequireExplicit/FlagNotVersion/cabal.test.hs --accept
  
$ echo $status
0

Run the test with a released version of cabal and it should fail:

$ cabal run cabal-testsuite:cabal-tests -- \
   --with-cabal=/home/.../.ghcup/bin/cabal \
   cabal-testsuite/PackageTests/RequireExplicit/FlagNotVersion/cabal.test.hs --accept
  
$ echo $status
1

Modify the test so that it will succeed for versions of cabal without this fix.

Tip

You may need to delete the named tests too that were added (appended) after these instructions.

$ diff --git a/cabal-testsuite/PackageTests/RequireExplicit/FlagNotVersion/cabal.test.hs b/cabal-testsuite/PackageTests/RequireExplicit/FlagNotVersion/cabal.test.hs
index 01f7429c1..4a617d2b1 100644
--- a/cabal-testsuite/PackageTests/RequireExplicit/FlagNotVersion/cabal.test.hs
+++ b/cabal-testsuite/PackageTests/RequireExplicit/FlagNotVersion/cabal.test.hs
@@ -1,4 +1,3 @@
 import Test.Cabal.Prelude
 main = cabalTest . recordMode RecordMarked $ withRepo "repo" $ do
-  res <- fails $ cabal' "v2-build" ["all", "--dry-run"]
-  assertOutputContains "not a user-provided goal" res
+  cabal "v2-build" ["all", "--dry-run"]

Run the test with a released version of cabal and observe the change in output:

$ cabal run cabal-testsuite:cabal-tests -- \
   --with-cabal=/home/.../.ghcup/bin/cabal \
   cabal-testsuite/PackageTests/RequireExplicit/FlagNotVersion/cabal.test.hs --accept

The change of output:

$ git diff
diff --git a/cabal-testsuite/PackageTests/RequireExplicit/FlagNotVersion/cabal.out b/cabal-testsuite/PackageTests/RequireExplicit/FlagNotVersion/cabal.out
index a3a5898e7..215cadb23 100644
--- a/cabal-testsuite/PackageTests/RequireExplicit/FlagNotVersion/cabal.out
+++ b/cabal-testsuite/PackageTests/RequireExplicit/FlagNotVersion/cabal.out
@@ -5,10 +5,7 @@
 Downloading the latest package list from test-local-repo
 # cabal v2-build
 Resolving dependencies...
-Error: [Cabal-7107]
-Could not resolve dependencies:
-[__0] trying: a-0 (user goal)
-[__1] next goal: some-lib (dependency of a)
-[__1] fail (not a user-provided goal nor mentioned as a constraint, but reject-unconstrained-dependencies was set)
-[__1] fail (backjumping, conflict set: a, some-lib)
-After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: a (2), some-lib (1)
+Build profile: -w ghc-<GHCVER> -O1
+In order, the following would be built:
+ - some-lib-1.0 (lib) (requires build)
+ - a-0 (lib) (first run)

Template Α: This PR modifies behaviour or interface

Include the following checklist in your PR:

@philderbeast
philderbeast force-pushed the fix/flag-as-version branch 5 times, most recently from 0f6a94b to 34cb954 Compare July 31, 2026 12:49
@philderbeast
philderbeast force-pushed the fix/flag-as-version branch from 77e147b to 94893f6 Compare July 31, 2026 13:11
@philderbeast
philderbeast requested review from sebright and sheaf July 31, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--reject-unconstrained-dependencies is satisfied by flag constraints

1 participant