Skip to content

Commit

Permalink
Force the Bazel server Java runtime to use the root locale
Browse files Browse the repository at this point in the history
This ensures consistent behavior of string operations even if the individual operations do not set a locale.

Without this change, Bazel can't operate in e.g. a Turkish locale, where it fails with error messages such as:

In rule 'test', size 'medium' is not a valid size.

This is because Turkish case mapping rules make it so that a capital ASCII 'I' lowercases to a non-ASCII variant of 'i'.

Fixes bazelbuild#17541

Closes bazelbuild#17702.

PiperOrigin-RevId: 515339563
Change-Id: I8417d0befd76ba6d140588be5f7e50529af3f6c7
  • Loading branch information
fmeum authored and ShreeM01 committed Mar 10, 2023
1 parent 94c519b commit 4421934
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/cpp/blaze.cc
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,13 @@ static vector<string> GetServerExeArgs(const blaze_util::Path &jvm_path,

// Force use of latin1 for file names.
result.push_back("-Dfile.encoding=ISO-8859-1");
// Force into the root locale to ensure consistent behavior of string
// operations across machines (e.g. in the tr_TR locale, capital ASCII 'I'
// turns into a special Unicode 'i' when converted to lower case).
// https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Locale.html#ROOT
result.push_back("-Duser.country=");
result.push_back("-Duser.language=");
result.push_back("-Duser.variant=");

if (startup_options.host_jvm_debug) {
BAZEL_LOG(USER)
Expand Down

0 comments on commit 4421934

Please sign in to comment.