`env_inherit` action cache key different for local and remote-cache
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the bug:
I've found that on `8.6.0` and `master` that using `env_inherit` behaves differently for local and remote caching. This feels like a bug, but perhaps is lack of documentation?
Variables specified in `env_inherit` are correctly excluded from the local action cache fingerprint (only var names are hashed, not values), but are incorrectly included with their resolved values in the remote cache action digest.
Local cache fingerprint: https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/actions/ActionEnvironment.java#L134-L138
Remote cache fingerprint: https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java#L555 https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java#L314-L319
### Which category does this issue belong to?
Core
### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Any test that uses `env_inherit` with a volatile env value will cache locally but not remotely.
### Which operating system are you running Bazel on?
ubuntu:24.04
### What is the output of `bazel info release`?
release 8.6.0
### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.
_No response_
### What's the output of `git remote get-url origin; git rev-parse HEAD` ?
```text
https://github.com/bazelbuild/bazel.git
56a8e33418fbe92180e9ec17d8567985370f81a3 (master)
f473e987e30ae64c852461b51eb8e69a8542a9e0 (8.6.0)
```
### If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.
not a regression, at least not in any recent timeframe
### Have you found anything relevant by searching the web?
There's plenty of discussion of users wanting to pass env vars to tests that are excluded from the action cache key. That is what I'm trying to do here. However specifically the different behavior with remote-cache seems like a bug.
### Any other information, logs, or outputs that you want to share?
_No response_
Contributor guide
Research direction
Start with ActionEnvironment.java lines 134-138 and RemoteExecutionService.java lines 314-319 and 555, then reproduce the env_inherit case with a volatile environment value against local and remote caching. Compare how each cache fingerprint or action digest is formed; done means env_inherit has consistent cache-key behavior between local and remote caches.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100