Skip to content

fix(env): give context env vars precedence over workspace vars - #16290

Merged
Alizter merged 1 commit into
ocaml:mainfrom
punchagan:fix-env-precedence
Sep 2, 2026
Merged

fix(env): give context env vars precedence over workspace vars#16290
Alizter merged 1 commit into
ocaml:mainfrom
punchagan:fix-env-precedence

Conversation

@punchagan

@punchagan punchagan commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Description

env vars defined in a (context ...) stanza are documented to have higher
precedence than env vars defined in the root env stanza of a workspace.
The prose in the cram test also indicates this, but the test asserted
incorrect precedence. This seems to have been indicated in a review
comment here and marked done, but may have been undone by an incorrect
rebase or something.

Only consumers of Super_context.context_env like dune exec were
affected by this. Rules were not affected since they resolved their
environment separately through Env_node.external_env which is not
affected by this bug.

Related Issue and Motivation

This issue was discovered while working on #15381

Checklist

  • Tests added, if applicable.
  • Change log entry added for any user-facing changes.
  • Documentation added for any user-facing changes.

Alizter added a commit that referenced this pull request Sep 1, 2026
To make the test easier to read and understand,
`env/env-variables/precedence.t/` has been converted to a single file
based test.

This is a preparatory PR for #16290/

## Checklist

- [ ] ~Tests added, if applicable.~
- [ ] ~[Change log entry
added](../CONTRIBUTING.md#updating-the-changelog) for any user-facing
changes.~
- [ ] ~Documentation added for any user-facing changes.~
@punchagan punchagan changed the title wip: fix env var precedence context vs workspace fix(env): give context env vars precedence over workspace vars Sep 1, 2026
env vars defined in a (context ...) stanza are documented to have higher
precedence than env vars defined in the root env stanza of a workspace.
The prose in the cram test also indicates this, but the test asserted
incorrect precedence. This seems to have been indicated in a review
comment [here] and marked done, but may have been undone by an incorrect
rebase or something.

Only consumers of Super_context.context_env like `dune exec` were
affected by this. Rules were not affected since they resolved their
environment separately through `Env_node.external_env` which is not
affected by this bug.

[here]: ocaml#1147 (comment)

Signed-off-by: Puneeth Chaganti <punchagan@muse-amuse.in>
@punchagan
punchagan requested a review from Alizter September 1, 2026 11:45
@punchagan
punchagan marked this pull request as ready for review September 1, 2026 11:45
@Alizter
Alizter requested a review from rgrinberg September 1, 2026 14:06
@Alizter
Alizter merged commit b9b14d8 into ocaml:main Sep 2, 2026
37 checks passed
@punchagan
punchagan deleted the fix-env-precedence branch September 3, 2026 02:31
@Alizter Alizter added this to the 3.25.0 milestone Sep 3, 2026
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.

2 participants