Skip to content

Commit

Permalink
Windows, sh_toolchain, bugfix: cast path to string
Browse files Browse the repository at this point in the history
When DetectBashOrDie [1] is commented out from
src/main/cpp/blaze.cc, and BAZEL_SH is unset,
and PATH is set and "bash" is found on the PATH,
then sh_configure successfully finds bash using
repository_ctx.which, and this method returns a
"path" object.

The code used to believe this was a string, and
called a string method on it, causing a runtime
error.

[1] https://github.com/bazelbuild/bazel/blob/2fda17d46088f2bb07b049fa35759002ea1dd5db/src/main/cpp/blaze.cc#L1543

Fixes bazelbuild#6498

Change-Id: I07fd36fd6c6e8433257b0394f1fc776bbe3e6928
  • Loading branch information
laszlocsomor committed Oct 25, 2018
1 parent 39a7cd7 commit 9528173
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tools/sh/sh_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ def _sh_config_impl(repository_ctx):
if _is_windows(repository_ctx):
sh_path = repository_ctx.which("bash.exe")
if sh_path:
# repository_ctx.which returns a path object, convert that to
# string so we can call string.startswith on it.
sh_path = str(sh_path)
# When the Windows Subsystem for Linux is installed there's a
# bash.exe under %WINDIR%\system32\bash.exe that launches Ubuntu
# Bash which cannot run native Windows programs so it's not what
Expand Down

0 comments on commit 9528173

Please sign in to comment.