Java RUNFILES_MANIFEST logic is lacking
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the bug:
[This logic](https://github.com/bazelbuild/bazel/blob/d9dc4fde4c8d06498f39b54a81d4e7fa1e5b5b30/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt#L196) seem incorrect in recent Bazel nightlies. I would expect it to look more [like so](https://github.com/bazelbuild/bazel/blob/d9dc4fde4c8d06498f39b54a81d4e7fa1e5b5b30/src/test/shell/integration/test_test.sh#L20C1-L24).
This breaks Java builds with `--noenable_runfiles`, especially anything using `rules_jvm_external` since it has an internal java binary (`AddJarManifestEntry`) that it runs on 3p deps, which fails at runtime with the following:
```
ERROR: /private/var/tmp/_bazel_david.zbarsky/5cb4fae43cf358e621837c0f9b3546d5/external/maven/BUILD:4727:11: Stamping the manifest of @@maven//:org_apache_kerby_kerb_server failed: (Exit 127): sandbox-exec failed: error executing StampJarManifest command
(cd /private/var/tmp/_bazel_david.zbarsky/5cb4fae43cf358e621837c0f9b3546d5/sandbox/darwin-sandbox/6890/execroot/_main && \
exec env - \
TMPDIR=/var/folders/ll/86ylz6g91fnf6x2c00jywg3m0000gq/T/ \
/usr/bin/sandbox-exec -f /private/var/tmp/_bazel_david.zbarsky/5cb4fae43cf358e621837c0f9b3546d5/sandbox/darwin-sandbox/6890/sandbox.sb /var/tmp/_bazel_david.zbarsky/install/d6daf49e33736f131b503f89e218c8fe/process-wrapper '--timeout=0' '--kill_delay=15' '--stats=/private/var/tmp/_bazel_david.zbarsky/5cb4fae43cf358e621837c0f9b3546d5/sandbox/darwin-sandbox/6890/stats.out' bazel-out/darwin_arm64-opt-exec-ST-13d3ddad9198/bin/external/rules_jvm_external~5.3/private/tools/java/com/github/bazelbuild/rules_jvm_external/jar/AddJarManifestEntry --source bazel-out/darwin_arm64-fastbuild/bin/external/maven/org/apache/kerby/kerb-server/1.0.1/kerb-server-1.0.1.jar --output bazel-out/darwin_arm64-fastbuild/bin/external/maven/org/apache/kerby/kerb-server/1.0.1/processed_kerb-server-1.0.1.jar --manifest-entry Target-Label:@@maven//:org_apache_kerby_kerb_server)
grep: /private/var/tmp/_bazel_david.zbarsky/5cb4fae43cf358e621837c0f9b3546d5/sandbox/darwin-sandbox/6890/execroot/_main/bazel-out/darwin_arm64-opt-exec-ST-13d3ddad9198/bin/external/rules_jvm_external~5.3/private/tools/java/com/github/bazelbuild/rules_jvm_external/jar/AddJarManifestEntry.runfiles/MANIFEST: No such file or directory
grep: /private/var/tmp/_bazel_david.zbarsky/5cb4fae43cf358e621837c0f9b3546d5/sandbox/darwin-sandbox/6890/execroot/_main/bazel-out/darwin_arm64-opt-exec-ST-13d3ddad9198/bin/external/rules_jvm_external~5.3/private/tools/java/com/github/bazelbuild/rules_jvm_external/jar/AddJarManifestEntry.runfiles/MANIFEST: No such file or directory
grep: /private/var/tmp/_bazel_david.zbarsky/5cb4fae43cf358e621837c0f9b3546d5/sandbox/darwin-sandbox/6890/execroot/_main/bazel-out/darwin_arm64-opt-exec-ST-13d3ddad9198/bin/external/rules_jvm_external~5.3/private/tools/java/com/github/bazelbuild/rules_jvm_external/jar/AddJarManifestEntry.runfiles/MANIFEST: No such file or directory
grep: /private/var/tmp/_bazel_david.zbarsky/5cb4fae43cf358e621837c0f9b3546d5/sandbox/darwin-sandbox/6890/execroot/_main/bazel-out/darwin_arm64-opt-exec-ST-13d3ddad9198/bin/external/rules_jvm_external~5.3/private/tools/java/com/github/bazelbuild/rules_jvm_external/jar/AddJarManifestEntry.runfiles/MANIFEST: No such file or directory
bazel-out/darwin_arm64-opt-exec-ST-13d3ddad9198/bin/external/rules_jvm_external~5.3/private/tools/java/com/github/bazelbuild/rules_jvm_external/jar/AddJarManifestEntry: line 399: exec: ::: not found
```
### Which category does this issue belong to?
_No response_
### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
_No response_
### Which operating system are you running Bazel on?
OSX
### What is the output of `bazel info release`?
release 7.0.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 master; git rev-parse HEAD` ?
_No response_
### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.
Yes, presumably from when the manifest file location changed name.
### Have you found anything relevant by searching the web?
_No response_
### Any other information, logs, or outputs that you want to share?
_No response_
Contributor guide
Research direction
Start in src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt at the RUNFILES_MANIFEST logic, then compare it with the setup in src/test/shell/integration/test_test.sh. Reproduce with --noenable_runfiles and the reported rules_jvm_external AddJarManifestEntry failure. Done means the Java tool runs without the missing MANIFEST errors and the relevant integration coverage passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, shell
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100