Allow File values in env of ctx.actions.run[_shell] - #29875
Open
fmeum wants to merge 1 commit into
Open
Conversation
fmeum
force-pushed
the
env-file-values
branch
5 times, most recently
from
June 19, 2026 11:50
e713016 to
bf1f420
Compare
The values of the `env` dict of `ctx.actions.run` and `ctx.actions.run_shell` can now be `File`s in addition to strings. Such values are expanded to the file's exec path at execution time, after path mapping has been applied. Compared to expanding the path during analysis, this allows environment variables referencing input or output paths to benefit from cross-configuration cache hits with `--experimental_output_paths=strip`. `ActionEnvironment` stores fixed variables in a single `ImmutableMap<String, /* String | Artifact */ Object>`. Since `Action#getEffectiveEnvironment` now receives a `PathMapper`, artifact values are resolved to their (possibly mapped) exec paths directly during resolution, so the method keeps returning `ImmutableMap<String, String>` and no caller needs to change. Analysis-time views (`getFixedEnv()`, the two-argument `resolve()`, aquery, `Action.env` in Starlark) resolve artifact values with `PathMapper.NOOP`, so their behavior is unchanged. The action key fingerprints artifact values with `PathMapper.forActionKey`, mirroring how command lines are fingerprinted; environments without artifact values produce byte-identical fingerprints as before.
fmeum
marked this pull request as ready for review
June 19, 2026 13:20
fmeum
requested review from
dabanki and
mai93
and removed request for
a team and
mai93
June 19, 2026 13:20
Collaborator
Author
|
FYI @keith |
Collaborator
Author
Collaborator
Author
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.
Adds support for path mappable environment variables by generalizing the existing custom support for C++ actions.
ActionEnvironmentis extended to allowArtifactvalues in addition toStringand the change is largely contained to that class, withgetEffectiveEnvironmentretaining itsMap<String, String>return value.RELNOTES: The values of the
envdict ofctx.actions.runandctx.actions.run_shellcan now beFiles in addition to strings to support path mapping environment variables (see #22658).