Skip to content

fix: replace existing version field in opam files during dune subst#14136

Open
robinbb wants to merge 1 commit intoocaml:mainfrom
robinbb:robinbb-fix-subst-duplicate-version-878
Open

fix: replace existing version field in opam files during dune subst#14136
robinbb wants to merge 1 commit intoocaml:mainfrom
robinbb:robinbb-fix-subst-duplicate-version-878

Conversation

@robinbb
Copy link
Copy Markdown
Contributor

@robinbb robinbb commented Apr 11, 2026

Summary

Fixes #878.

When an opam file already contains a version: field, dune subst prepends a new version: line instead of replacing the existing one. This results in duplicate version fields:

version: "1.0"
opam-version: "2.0"
version: "dev"
depends: [ "dune" ]

The fix checks for an existing version: line using Re and replaces it in place rather than always prepending.

@robinbb robinbb force-pushed the robinbb-fix-subst-duplicate-version-878 branch from 592d985 to 37828b6 Compare April 11, 2026 03:06
…caml#878)

When an opam file already contains a version: field, dune subst was
prepending a new version: line instead of replacing the existing one,
resulting in duplicate version fields.

Fix by checking for an existing version: line and replacing it in
place rather than always prepending.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
@robinbb robinbb force-pushed the robinbb-fix-subst-duplicate-version-878 branch from 37828b6 to 1a9c6f9 Compare April 11, 2026 03:08
@rgrinberg
Copy link
Copy Markdown
Member

Could you add a change log entry?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dune subst can add a duplicate version field in opam

2 participants