bazel-contrib / bazel-contrib/bazel-lib
Windows native launcher fails with directory-based runfiles
- Dominant language
- Starlark
- Stars
- 182
- Forks
- 134
- Avg merge
- 1d 46m
- Merged PRs (30d)
- 1
Description
`create_windows_native_launcher_script` in `lib/windows_utils.bzl` currently forces:
```bat
set RUNFILES_MANIFEST_ONLY=1
```
and its `:rlocation` implementation requires a runfiles manifest.
This fails for Windows remote execution environments where Bazel provides a runfiles directory but no manifest. Bazel’s native Windows launcher supports this case by falling back to directory-based lookup through `RUNFILES_DIR`.
### Current behavior
When the generated launcher runs without a manifest, it exits with an error similar to:
```text
ERROR: Manifest file ... does not exist.
```
The non-manifest branch in `:rlocation` also returns the logical runfiles path unchanged rather than resolving it relative to `%RUNFILES_DIR%`, so removing `RUNFILES_MANIFEST_ONLY=1` alone would not fix the issue.
### Expected behavior
The generated launcher should support both standard Windows runfiles layouts:
1. Use `RUNFILES_MANIFEST_FILE` when a valid manifest is available.
2. Otherwise resolve runfiles relative to `RUNFILES_DIR`.
3. When neither variable identifies a valid location, discover the usual adjacent manifest and `.runfiles` paths.
This would match the behavior of Bazel’s native [Windows launcher](https://github.com/bazelbuild/bazel/blob/df5a815925dfb5acfbedbd799fdfc18d153fa634/src/tools/launcher/launcher.cc#L81), which supports manifest-based local execution and directory-based remote execution.
### Relevant code
* `lib/windows_utils.bzl`
* `create_windows_native_launcher_script`
* The generated batch file’s `:rlocation` routine
### Prior work
PR #872 implemented this fallback as part of a broader Runfiles v3 change:
That PR was closed after a request to split it into smaller, independently reviewable changes. This issue is intended to track only the Windows manifest-to-directory fallback.
A targeted fix could extract the relevant behavior from that PR without including its unrelated test and runfiles changes.
Contributor guide
Research direction
Start in lib/windows_utils.bzl at create_windows_native_launcher_script and inspect the generated batch file’s :rlocation routine. Review the relevant fallback behavior from PR #872, then verify that the launcher handles a valid RUNFILES_MANIFEST_FILE, a RUNFILES_DIR without a manifest, and adjacent manifest or .runfiles paths when neither variable is usable.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100