Skip to content

Commit

Permalink
Windows, Bash launcher: Make sure bash bin tool directory is in PATH
Browse files Browse the repository at this point in the history
If bash_bin_path exists, we add it's directory to PATH to make bash bin tools available.
If bash_bin_path doesn't exist, there are two cases:
   1. bash.exe is in PATH, and that means bash bin tools should also be in PATH.
   2. bash.exe isn't in PATH, the launcher will fail with "The system cannot find the file
      specified." error.

RELNOTES: None
PiperOrigin-RevId: 208182717
  • Loading branch information
meteorcloudy authored and Copybara-Service committed Aug 10, 2018
1 parent ee0ad1a commit 7aaa34a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/tools/launcher/bash_launcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,15 @@ static constexpr const char* BASH_BIN_PATH = "bash_bin_path";

ExitCode BashBinaryLauncher::Launch() {
wstring bash_binary = this->GetLaunchInfoByKey(BASH_BIN_PATH);
// If specified bash binary path doesn't exist, then fall back to
// bash.exe and hope it's in PATH.
if (!DoesFilePathExist(bash_binary.c_str())) {
if (DoesFilePathExist(bash_binary.c_str())) {
wstring bash_bin_dir = GetParentDirFromPath(bash_binary);
wstring path_env;
GetEnv(L"PATH", &path_env);
path_env = bash_bin_dir + L";" + path_env;
SetEnv(L"PATH", path_env);
} else {
// If specified bash binary path doesn't exist, then fall back to
// bash.exe and hope it's in PATH.
bash_binary = L"bash.exe";
}

Expand Down

0 comments on commit 7aaa34a

Please sign in to comment.