Skip to content

Commit

Permalink
Do not forward legacy cmd.exe variables to the server
Browse files Browse the repository at this point in the history
This fixes startup failures such as:
```
ERROR: While parsing option --client_env==C:=C:\Users\wyv: Variable definitions must be in the form of a 'name=value' assignment
```
  • Loading branch information
fmeum committed Nov 22, 2024
1 parent 90023d2 commit b757417
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/cpp/option_processor_windows.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@ static void PreprocessEnvString(std::string* env_str) {
#endif // defined(__CYGWIN__)

static bool IsValidEnvName(std::string_view s) {
std::string_view name = s.substr(0, s.find('='));
std::size_t first_equal = s.find('=');
if (first_equal == 0) {
// Skip over legacy environment variables that start with '=', e.g. '=C:'
// These are set by cmd.exe and can't be parsed by the Bazel server if
// passed into --client_env.
return false;
}
std::string_view name = s.substr(0, first_equal);
return std::all_of(name.begin(), name.end(), [](char c) {
return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') ||
(c >= '0' && c <= '9') || c == '_' || c == '(' || c == ')';
Expand Down

0 comments on commit b757417

Please sign in to comment.