From 4d269d747f23af87db45fc840670330ff59b55f8 Mon Sep 17 00:00:00 2001 From: Laszlo Csomor Date: Wed, 18 Apr 2018 00:38:57 -0700 Subject: [PATCH] windows: GetOutputRoot() returns GetHomeDir() This is an immediate fix for a very nasty bug: https://github.com/bazelbuild/bazel/issues/5038 Change-Id: I5e4f9fa13e5ac785514bc0dc4ce6cba9a88f33bb Closes #5039. Change-Id: I5e4f9fa13e5ac785514bc0dc4ce6cba9a88f33bb PiperOrigin-RevId: 193315571 --- src/main/cpp/blaze_util_windows.cc | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/main/cpp/blaze_util_windows.cc b/src/main/cpp/blaze_util_windows.cc index 8097413309225c..95517f3e969de3 100644 --- a/src/main/cpp/blaze_util_windows.cc +++ b/src/main/cpp/blaze_util_windows.cc @@ -202,19 +202,12 @@ string GetSelfPath() { } string GetOutputRoot() { - for (const char* i : {"TMPDIR", "TEMPDIR", "TMP", "TEMP"}) { - string tmpdir(GetEnv(i)); - if (!tmpdir.empty()) { - return tmpdir; - } - } - - WCHAR buffer[kWindowsPathBufferSize] = {0}; - if (!::GetTempPathW(kWindowsPathBufferSize, buffer)) { - die(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR, - "GetOutputRoot: GetTempPathW: %s", GetLastErrorString().c_str()); + string home = GetHomeDir(); + if (home.empty()) { + BAZEL_DIE(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR) + << "Cannot find a good output root. Use the --output_user_root flag."; } - return string(blaze_util::WstringToCstring(buffer).get()); + return home; } string GetHomeDir() {