Repository navigation
fix: deduplicate dune version bounds in generated opam files - #14175
Merged
Leonidas-from-XIV merged 7 commits intoApr 14, 2026
Merged
Conversation
When users declare an explicit dune dependency with a >= constraint
that matches or exceeds the (lang dune X.Y) version, the generated
opam file no longer contains redundant duplicate bounds like
{>= "2.7" & >= "2.7"} or {>= "3.16" & >= "3.16.0"}.
The fix uses OpamVersionCompare to keep only the more restrictive
of the two >= bounds. Other constraint shapes (=, or, and, etc.)
continue to be combined with & as before.
Fixes ocaml#3916
Fixes ocaml#11106
Signed-off-by: Robin Bate Boerop <[email protected]>
Signed-off-by: Robin Bate Boerop <[email protected]>
Leonidas-from-XIV
requested changes
Apr 13, 2026
Address reviewer feedback: match the depends block by its delimiters rather than hardcoding a line count. Signed-off-by: Robin Bate Boerop <[email protected]>
Replace sed range patterns with the project's own dune_cmd helpers, which are clearer and don't assume section-closing ] appears at the start of a line. Signed-off-by: Robin Bate Boerop <[email protected]>
Clarifies which constraint comes from (lang dune X.Y) and which from the user's (depends ...) stanza. Signed-off-by: Robin Bate Boerop <[email protected]>
When the user specifies a dune dependency like (dune (>= 2.5)) but uses (lang dune 2.7), emit a warning explaining that the generated opam file will use the higher lang version bound instead. Signed-off-by: Robin Bate Boerop <[email protected]>
Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb
marked this pull request as ready for review
April 13, 2026 18:01
Collaborator
Author
|
@Leonidas-from-XIV Back to you. |
Leonidas-from-XIV
approved these changes
Apr 14, 2026
robinbb
added a commit
to robinbb/dune
that referenced
this pull request
May 9, 2026
PR ocaml#14175 added deduplication of redundant `>=` bounds on the `dune` dependency in generated opam files (e.g. `{>= "3.17" & >= "3.20"}` collapsing to `{>= "3.20"}`), but did so without a lang-version guard. As a result, simply upgrading the dune binary to 3.23 changed the generated opam output for projects whose `(lang dune X.Y)` had not changed (issue ocaml#14436). Gate the new behaviour on `(lang dune 3.23)`, the lang version under which the dedup feature shipped. Projects at earlier lang versions get the pre-14175 `And [lang; user]` shape. The accompanying user warning (lower bound < lang version) is also gated, since it lives inside `merge_dune_constraints`. Fixes ocaml#14436 Signed-off-by: Robin Bate Boerop <[email protected]>
shonfeder
pushed a commit
that referenced
this pull request
May 10, 2026
## Summary Gate the dune-version-bound deduplication in generated opam files (introduced in #14175 and shipped in 3.23.0) on `(lang dune 3.23)`. Projects at earlier lang versions get the pre-14175 `And [lang; user]` shape. Fixes #14436 Related: #14175 (cherry picked from commit eb4a64a) Signed-off-by: Robin Bate Boerop <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
(dune (>= X.Y))dependency matching or exceeding the(lang dune X.Y)version, the generated opam file no longer contains redundant duplicate bounds like{>= "2.7" & >= "2.7"}or{>= "3.16" & >= "3.16.0"}OpamVersionCompareto keep only the more restrictive of the two>=bounds; other constraint shapes (=,or,and, etc.) continue to be combined with&as beforeFixes #3916
Fixes #11106