fix: Windows spaces in manifest paths - #1296
Merged
fmeum merged 2 commits intoSep 16, 2026
Merged
Conversation
The batch rlocation helper parsed manifest lines with
`for /F "tokens=2*"` and kept only `%%i`, the first space-delimited word
of the target path. Bazel escapes a manifest entry only when the
RLOCATION path contains a space or a newline, marking such lines with a
leading space; in an unescaped line the first space is the separator and
everything after it is the target, spaces included. Keeping `%%i`
therefore truncated every target under a path like
C:/Users/First Last/... to C:/Users/First.
Every consumer of BATCH_RLOCATION_FUNCTION was affected. diff_test, for
example, reported
ERROR: Cannot compare directory "_main/pkg/_gendir" and a file
"_main/pkg/src/generated"
because the source directory resolved to a path that does not exist, so
its `if exist` check failed. Split on the first space instead.
Resolving the path correctly then exposed a second defect: the launcher
invoked `bash -c "!run_script! !args!"` unquoted, so bash word-split the
now-correct path at its spaces. Quote it.
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
…dstr create_windows_native_launcher_script declares the .bat as a sibling of the shell script it runs, so in the common case the payload sits next to the launcher and can be named directly from %~dp0 plus a basename known at analysis time. Doing that first avoids two failure modes of the manifest lookup, both reported in bazel-contrib#1287: findstr.exe cannot open a manifest whose path exceeds MAX_PATH, which LongPathsEnabled does not lift for cmd.exe built-ins; and when Bazel invokes the .bat through its 8.3 short-path alias, %~f0.runfiles expands to a directory that does not exist, because 8.3 aliases are allocated per file and a literal suffix cannot be appended to one. The manifest lookup is kept as a fallback for when the sibling is absent, so launchers staged apart from their payload keep working. Signed-off-by: Austin Schuh <austin.linux@gmail.com>
fmeum
approved these changes
Sep 16, 2026
fmeum
enabled auto-merge (squash)
September 16, 2026 11:12
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.
The batch rlocation helper parsed manifest lines with
for /F "tokens=2*"and kept only%%i, the first space-delimited wordof the target path. Bazel escapes a manifest entry only when the
RLOCATION path contains a space or a newline, marking such lines with a
leading space; in an unescaped line the first space is the separator and
everything after it is the target, spaces included. Keeping
%%itherefore truncated every target under a path like
C:/Users/First Last/... to C:/Users/First.
Every consumer of BATCH_RLOCATION_FUNCTION was affected. diff_test, for
example, reported
ERROR: Cannot compare directory "_main/pkg/_gendir" and a file
"_main/pkg/src/generated"
because the source directory resolved to a path that does not exist, so
its
if existcheck failed. Split on the first space instead.Resolving the path correctly then exposed a second defect: the launcher
invoked
bash -c "!run_script! !args!"unquoted, so bash word-split thenow-correct path at its spaces. Quote it.