Repository navigation
Open
Description
Please also mention that while
cabal.project.freezerestricts specified dependency versions, it does NOT prevent from including future dependencies unlessreject-unconstrained-dependencies=allis specified
Originally posted by @LaurentRDC in #9984
I had a look at --reject-unconstrained-dependencies=all and this only requires that there is some version constraint on each dependency. Could we add another value to this flag that requires version equality constraints?
$ git diff HEAD~3 HEAD~2
diff --git a/doc/cabal-project-description-file.rst b/doc/cabal-project-description-file.rst
index fa6b22960..5b7e4d332 100644
--- a/doc/cabal-project-description-file.rst
+++ b/doc/cabal-project-description-file.rst
@@ -790,8 +790,8 @@ The following settings control the behavior of the dependency solver:
active-repositories: :none
-.. cfg-field:: reject-unconstrained-dependencies: all, none
- --reject-unconstrained-dependencies=[all|none]
+.. cfg-field:: reject-unconstrained-dependencies: eq, all, none
+ --reject-unconstrained-dependencies=[eq|all|none]
:synopsis: Restrict the solver to packages that have constraints on them.
:default: none
@@ -801,9 +801,11 @@ The following settings control the behavior of the dependency solver:
aware of in a build plan. If you wish to restrict the build plan to
a closed set of packages (e.g., from a freeze file), use this flag.
- When set to `all`, all non-local packages that aren't goals must be
- explicitly constrained. When set to `none`, the solver will
- consider all packages.
+ When set to `eq` or `all`, all non-local packages that aren't goals must be
+ explicitly constrained, where `all` accepts any version constraint and `eq`
+ accepts version ranges that normalise to an equality constraint.
+
+ When set to `none`, the solver will consider all packages.
Activity
sebright commentedon Feb 2, 2026
What is the use case for
--reject-unconstrained-dependencies=eq? I thought that--reject-unconstrained-dependencies=allwould normally be used with a freeze file, which is supposed to only use equality constraints.--reject-unconstrained-dependenciesjust ensures that the project doesn't add more dependencies beyond the set of dependencies that was present when the freeze file was created.philderbeast commentedon Feb 18, 2026
While a freeze file is best created with
cabal freeze, it is an implicitly imported project file and can be created or modified (tampered with) by other means. I agree that--reject-unconstrained-dependencies=allis good enough for checking acabal freezecreated freeze file to see if some constraints are missing.I can trick the check quite easily by editing the freeze file to relax the version constraints. If I freeze this project, the check passes.
I can relax the version equality constraint on
rereusing a wildcard.With the above changes,
--reject-unconstrained-dependencies=alllets this pass but--reject-unconstrained-dependencies=eqcatches the problem:I can go further to accept any version of
rere:Again,
=alllets this pass but=eqsaysrereis an unconstrained dependency. I get the same result if I replace>0with-any.If I comment out
rerethere's no reported problem with=all. Again=eqsaysrereis unconstrained.Is
rerenot actually used with build targetsall? One package,Cabal-describedhas a dependency onrereand this package is included incabal.projectvia the import ofproject-cabal/pkgs/cabal.config.sebright commentedon Jun 8, 2026
@philderbeast Sorry I missed your reply. I wonder if most users would prefer that
--reject-unconstrained-dependenciesalways check for equality constraints. Do you know whether there is a use case for only checking for the existence of any constraint, no matter how loose? Should we just change the default behavior?EDIT: Maybe the current behavior is a workaround for #9799/#3502.
This really seems like a bug to me. I wonder if
--reject-unconstrained-dependenciesis satisfied by the flag constraints on the next line.Mikolaj commentedon Jun 18, 2026
@sheaf: would you have any clue regarding @sebright's question ^^^?
sheaf commentedon Jun 18, 2026
No, sorry. It seems like it would be worth trying to see what errors we get if we remove the
rere -rere-cfg -rere-intersectionline and try again.philderbeast commentedon Jun 18, 2026
I tried removing the line with the
rereflags as well (so bothrerelines removed) and the behaviour is the same as deleting only the line in the freeze file with the version equality constraints forrere,=alldoesn't notice and is happy to build but=eqdoes and refuses the build.sebright commentedon Jun 22, 2026
I wonder what constraint is satisfying
--reject-unconstrained-dependencies=all. The-v3log would probably show the constraint forrereif there is one. If there is already a serious bug in--reject-unconstrained-dependencies=all, then I think that there is less reason to preserve the existing behavior.philderbeast commentedon Jul 5, 2026
Yes I agree. Before replacing the implementation, I'd like to track down this bug.
philderbeast commentedon Jul 26, 2026
There are flags set for
rere:cabal/project-cabal/constraints.config
Line 2 in 39955a8
I can make
--reject-unconstrained-dependencies=allwork with additional filtering of flags but will have to take care with-anyand-none, deprecated flags that relate to versions.Here's a snippet of my test
.freezefile with some of the stuff I'm testing on the fly (all commented out):How does project files not being versioned affect how we handle
-anyand-noneflags? With debugging, it looks like they're still accepted.