Skip to content

Reject unconstrained dependency = none|all|eq - #11470

Open
philderbeast wants to merge 1 commit into
haskell:masterfrom
cabalism:add/constrain-eq-version
Open

philderbeast wants to merge 1 commit into
haskell:masterfrom
cabalism:add/constrain-eq-version

Conversation

@philderbeast

@philderbeast philderbeast commented Feb 2, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #11468. Adds an eq value for --reject-unconstrained-dependencies.

With eq, every non-local package that isn't a goal must have a version constraint that allows exactly one version. This is the setting to use with a freeze file: cabal freeze then --reject-unconstrained-dependencies=eq holds the build plan to the frozen set.

When solving fails, the message now includes the option value, whether it was given as =all or =eq (it shouldn't fail with =none).

Solver Changes

The solver prune step, onlyConstrained, fails a package choice when a predicate on the package name is false. Here we add one more case, that uses a new isThisVersion predicate with the existing filterVersion function. The predicate does a normalised version equality check.

The solver's search is untouched and =all and =none cases are unchanged

Manual QA

With this repository, cabal freeze.

Edit cabal.project.freeze commenting out the line for the pretty dependency.

-             any.pretty ==1.1.3.6,
+          -- any.pretty ==1.1.3.6,

Now cabal build cabal-install-solver --reject-unconstrained-dependencies=? will only build when ? is none.

Edit cabal.project.freeze changing the line for the pretty dependency.

-             any.pretty ==1.1.3.6,
+             any.pretty >0,

Now cabal build --reject-unconstrained-dependencies=? will build when ? is none|all but won't build when ? is eq.

$ cabal build cabal-install-solver --reject-unconstrained-dependencies=eq
Warning: this is a debug build of cabal-install with assertions enabled.
Resolving dependencies...
Error: [Cabal-7107]
Could not resolve dependencies:
[__0] trying: Cabal-3.19.0.0 (user goal)
[__1] next goal: pretty (dependency of Cabal)
[__1] fail (not a user-provided goal nor mentioned as a constraint when reject-unconstrained-dependencies=eq)
[__1] fail (backjumping, conflict set: Cabal, pretty)
After searching the rest of the dependency tree exhaustively,
  these were the goals I've had most trouble fulfilling: Cabal, pretty

Template Α: This PR modifies behaviour or interface

Include the following checklist in your PR:

@philderbeast philderbeast changed the title Add/constrain eq version Reject unconstrained dependency = none|all|eq Feb 2, 2026
@philderbeast
philderbeast force-pushed the add/constrain-eq-version branch from 0ddde8d to 4142036 Compare February 2, 2026 02:48
@philderbeast
philderbeast marked this pull request as draft February 3, 2026 12:09
@philderbeast
philderbeast force-pushed the add/constrain-eq-version branch 11 times, most recently from 8edde84 to c5d436a Compare February 10, 2026 16:24
@philderbeast
philderbeast force-pushed the add/constrain-eq-version branch 2 times, most recently from 3e4a2ef to 6165816 Compare February 24, 2026 14:05
@philderbeast
philderbeast force-pushed the add/constrain-eq-version branch 4 times, most recently from e9feef8 to e87fb1a Compare March 4, 2026 14:43
@philderbeast
philderbeast force-pushed the add/constrain-eq-version branch from e87fb1a to 0151c4a Compare March 8, 2026 14:37
@philderbeast
philderbeast force-pushed the add/constrain-eq-version branch 3 times, most recently from d7b6fd7 to 8339ba1 Compare March 26, 2026 14:50
@philderbeast
philderbeast force-pushed the add/constrain-eq-version branch 3 times, most recently from 6c0a75b to 25aaa3f Compare April 2, 2026 16:12
@philderbeast
philderbeast force-pushed the add/constrain-eq-version branch from 25aaa3f to 57d0494 Compare April 5, 2026 16:01
@philderbeast
philderbeast force-pushed the add/constrain-eq-version branch from 57d0494 to f3c69ab Compare April 15, 2026 18:01
@philderbeast
philderbeast force-pushed the add/constrain-eq-version branch from f3c69ab to 39e818d Compare May 2, 2026 19:07
@philderbeast
philderbeast force-pushed the add/constrain-eq-version branch 3 times, most recently from 29e84ab to 8341254 Compare May 28, 2026 00:54
@philderbeast
philderbeast requested a review from sebright May 28, 2026 00:57
@philderbeast
philderbeast force-pushed the add/constrain-eq-version branch from 8341254 to 0fcc8b3 Compare June 2, 2026 16:20
@philderbeast philderbeast mentioned this pull request Jun 3, 2026
1 of 2 tasks
@philderbeast
philderbeast force-pushed the add/constrain-eq-version branch 5 times, most recently from 1465b97 to d2cdd8a Compare June 11, 2026 10:49
@philderbeast
philderbeast force-pushed the add/constrain-eq-version branch 2 times, most recently from d5d6e65 to 725ef5a Compare June 20, 2026 17:25
@philderbeast
philderbeast force-pushed the add/constrain-eq-version branch 2 times, most recently from c8a3290 to cb5b319 Compare July 1, 2026 18:37
@philderbeast
philderbeast force-pushed the add/constrain-eq-version branch from cb5b319 to 660f6ad Compare July 5, 2026 13:54
@philderbeast
philderbeast force-pushed the add/constrain-eq-version branch 2 times, most recently from 39b0135 to 142b86d Compare July 25, 2026 13:25
@philderbeast
philderbeast force-pushed the add/constrain-eq-version branch 3 times, most recently from e4c14fb to c775f69 Compare July 31, 2026 14:31
@philderbeast
philderbeast force-pushed the add/constrain-eq-version branch from c775f69 to a39ba27 Compare November 12, 2026 15:47
@mergify mergify Bot added the 👻 haunting the review queue Set by Mergify: no review from anyone with write access two weeks after opening label Nov 12, 2026
@philderbeast
philderbeast force-pushed the add/constrain-eq-version branch 2 times, most recently from 86513d3 to 65ba12b Compare November 12, 2026 17:58
- Update test for == constraint check
- Add OnlyConstrainedEq
- Test --reject-unconstrained-dependencies=eq
- Add haddocks for eq option
- Show flag setting in FailReason
- Use onlyConstrainedAll in solver unit tests
- Add unit tests for =eq and =none
- Use normalise not normaliseVersionRange
- Add freeze then =eq test
- Add prop tests for reject-unconstrained-dependencies
@philderbeast
philderbeast force-pushed the add/constrain-eq-version branch from 65ba12b to e7dc21a Compare November 12, 2026 18:00
@philderbeast

philderbeast commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator Author

I've rebased this since the #12191 change merged and then added more tests, including property tests. I've updated the description and included a section about the very limited solver changes.

One design point I'd like an opinion on: each constraint is checked on its own, so >=1 and <=1 given as two constraints don't satisfy =eq, but a single >=1 && <=1 constraint does. That is documented and tested. Please let me know if you think it should work differently.

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

Labels

attention: needs-review 👻 haunting the review queue Set by Mergify: no review from anyone with write access two weeks after opening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

reject-unconstrained-dependencies=eq

1 participant