Skip to content

Commit

Permalink
Use case-insensitive comparison for Windows paths in runfiles.bash
Browse files Browse the repository at this point in the history
When matching the path of `rlocation`'s caller in the Bash runfiles
library, use a case-insensitive comparison when running in MSYS2 as
Bazel emits paths that can be capitalized differently. In particular,
this fixes failures when the output base path contains uppercase
letters.
  • Loading branch information
fmeum committed Sep 23, 2023
1 parent 48b2e85 commit 9cf5a18
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tools/bash/runfiles/runfiles.bash
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,14 @@ function runfiles_current_repository() {
# uses / as the path separator even on Windows.
local -r normalized_caller_path="$(echo "$caller_path" | sed 's|\\\\*|/|g')"
local -r escaped_caller_path="$(echo "$normalized_caller_path" | sed 's/[^-A-Za-z0-9_/]/\\&/g')"
rlocation_path=$(__runfiles_maybe_grep -m1 "^[^ ]* ${escaped_caller_path}$" "${RUNFILES_MANIFEST_FILE}" | cut -d ' ' -f 1)
if [[ "$(uname -o)" == Msys ]]; then
# Windows paths are case insensitive and Bazel and MSYS2 capitalize differently, so we can't
# assume that all paths are in the same native case.
local -r grep_arg="-i"
else
local -r grep_arg=
fi
rlocation_path=$(__runfiles_maybe_grep "$grep_arg" -m1 "^[^ ]* ${escaped_caller_path}$" "${RUNFILES_MANIFEST_FILE}" | cut -d ' ' -f 1)
if [[ -z "$rlocation_path" ]]; then
if [[ "${RUNFILES_LIB_DEBUG:-}" == 1 ]]; then
echo >&2 "ERROR[runfiles.bash]: runfiles_current_repository($idx): ($normalized_caller_path) is not the target of an entry in the runfiles manifest ($RUNFILES_MANIFEST_FILE)"
Expand Down

0 comments on commit 9cf5a18

Please sign in to comment.