diff --git a/src/main/cpp/blaze.cc b/src/main/cpp/blaze.cc index f31155ff0a6cdb..da1dc5ff175c5b 100644 --- a/src/main/cpp/blaze.cc +++ b/src/main/cpp/blaze.cc @@ -1546,7 +1546,7 @@ int Main(int argc, const char *argv[], WorkspaceLayout *workspace_layout, // Must be done before command line parsing. // ParseOptions already populate --client_env, so detect bash before it // happens. - DetectBashOrDie(); + (void) DetectBashAndExportBazelSh(); #endif // if defined(_WIN32) || defined(__CYGWIN__) globals->binary_path = CheckAndGetBinaryPath(argv[0]); diff --git a/src/main/cpp/blaze_util_platform.h b/src/main/cpp/blaze_util_platform.h index 832bfe0eca8065..3686aa72c238fb 100644 --- a/src/main/cpp/blaze_util_platform.h +++ b/src/main/cpp/blaze_util_platform.h @@ -264,7 +264,6 @@ bool UnlimitCoredumps(); #if defined(_WIN32) || defined(__CYGWIN__) std::string DetectBashAndExportBazelSh(); -void DetectBashOrDie(); #endif // if defined(_WIN32) || defined(__CYGWIN__) // This function has no effect on Unix platforms. diff --git a/src/main/cpp/blaze_util_windows.cc b/src/main/cpp/blaze_util_windows.cc index b113c54dfefd45..a89a9afe5c59d0 100644 --- a/src/main/cpp/blaze_util_windows.cc +++ b/src/main/cpp/blaze_util_windows.cc @@ -1452,17 +1452,9 @@ static string GetBinaryFromPath(const string& binary_name) { return string(); } -static string LocateBash() { +static string LocateBashMaybe() { string msys_bash = GetMsysBash(); - if (!msys_bash.empty()) { - return msys_bash; - } - - string result = GetBinaryFromPath("bash.exe"); - if (result.empty()) { - BAZEL_LOG(ERROR) << "bash.exe not found on PATH"; - } - return result; + return msys_bash.empty() ? GetBinaryFromPath("bash.exe") : msys_bash; } string DetectBashAndExportBazelSh() { @@ -1473,33 +1465,19 @@ string DetectBashAndExportBazelSh() { uint64_t start = blaze::GetMillisecondsMonotonic(); - bash = LocateBash(); + bash = LocateBashMaybe(); uint64_t end = blaze::GetMillisecondsMonotonic(); - BAZEL_LOG(INFO) << "BAZEL_SH detection took " << end - start - << " msec, found " << bash.c_str(); - - if (!bash.empty()) { + if (bash.empty()) { + BAZEL_LOG(INFO) << "BAZEL_SH detection took " << end - start + << " msec, not found"; + } else { + BAZEL_LOG(INFO) << "BAZEL_SH detection took " << end - start + << " msec, found " << bash.c_str(); // Set process environment variable. blaze::SetEnv("BAZEL_SH", bash); } - return bash; -} -void DetectBashOrDie() { - string bash = DetectBashAndExportBazelSh(); - if (bash.empty()) { - // TODO(bazel-team) should this be printed to stderr? If so, it should use - // BAZEL_LOG(ERROR) - printf( - "Bazel on Windows requires MSYS2 Bash, but we could not find it.\n" - "If you do not have it installed, you can install MSYS2 from\n" - " http://repo.msys2.org/distrib/msys2-x86_64-latest.exe\n" - "\n" - "If you already have it installed but Bazel cannot find it,\n" - "set BAZEL_SH environment variable to its location:\n" - " set BAZEL_SH=c:\\path\\to\\msys2\\usr\\bin\\bash.exe\n"); - exit(1); - } + return bash; } void EnsurePythonPathOption(std::vector* options) {