Skip to content

Commit

Permalink
Rollback of commit 8bb4299.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

Suspected root cause for Windows bootstrap on Bazel CI breakage:

java.lang.NullPointerException
	at com.google.devtools.build.lib.vfs.Path$1.run(Path.java:123)

http://ci.bazel.io/view/Bazel%20bootstrap%20and%20maintenance/job/Bazel/922/JAVA_VERSION=1.8,PLATFORM_NAME=windows-x86_64/console

*** Original change description ***

VFS, WindowsFileSystem: fix UNIX_ROOT retrieval

Executing bash.exe directly instead of through
cmd.exe doesn't seem to work. This change fixes
that problem.

Fixes #1463 (again)

--
MOS_MIGRATED_REVID=136581532
  • Loading branch information
philwo committed Oct 19, 2016
1 parent f04dfb9 commit 4b4b9d3
Showing 1 changed file with 10 additions and 27 deletions.
Expand Up @@ -20,7 +20,6 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.LinkOption;
Expand Down Expand Up @@ -171,11 +170,9 @@ private static WindowsPath translateParent(WindowsPath parent, String name) {
UNIX_ROOT,
"Could not determine Unix path root or it is not an absolute Windows path. Set the "
+ "\"%s\" JVM argument, or export the \"%s\" environment variable for the MSYS bash"
+ " and have /usr/bin/cygpath installed. Parent is \"%s\", name is \"%s\".",
+ " and have /usr/bin/cygpath installed",
WINDOWS_UNIX_ROOT_JVM_ARG,
BAZEL_SH_ENV_VAR,
parent,
name);
BAZEL_SH_ENV_VAR);

return (WindowsPath) parent.getRelative(UNIX_ROOT);
} else {
Expand Down Expand Up @@ -411,19 +408,19 @@ private static PathFragment determineUnixRoot(String jvmArgName, String bazelShE
String bash = System.getenv(bazelShEnvVar);
Process process = null;
try {
process = Runtime.getRuntime().exec("cmd.exe /C " + bash + " -c \"/usr/bin/cygpath -m /\"");
process = Runtime.getRuntime().exec(bash + "-c \"/usr/bin/cygpath -m /\"");

// Wait 3 seconds max, that should be enough to run this command.
process.waitFor(3, TimeUnit.SECONDS);

if (process.exitValue() == 0) {
path = readAll(process.getInputStream());
} else {
System.err.print(
String.format(
"ERROR: %s (exit code: %d)%n",
readAll(process.getErrorStream()),
process.exitValue()));
char[] buf = new char[256];
try (InputStreamReader r = new InputStreamReader(process.getInputStream())) {
int len = 0;
while ((len = r.read(buf)) > 0) {
path = path + new String(buf, 0, len);
}
}
}
} catch (InterruptedException | IOException e) {
// Silently ignore failure. Either MSYS is installed at a different location, or not
Expand All @@ -440,18 +437,4 @@ private static PathFragment determineUnixRoot(String jvmArgName, String bazelShE
return result;
}
}

private static String readAll(InputStream s) {
String result = "";
int len;
char[] buf = new char[4096];
try (InputStreamReader r = new InputStreamReader(s)) {
while ((len = r.read(buf)) > 0) {
result += new String(buf, 0, len);
}
} catch (IOException e) {
return null;
}
return result;
}
}

0 comments on commit 4b4b9d3

Please sign in to comment.