src/goInstallTools.ts: handle stderr of go env
Previously, the extension stopped working if 'go env' fails
to run cleanly (no stderr, no non-zero exit code). But,
'go env' may output warnings about potential misconfiguration.
Show the messages to users, but keep going upon non null stderr.
Fixes golang/vscode-go#682
Change-Id: I3364314b8e96b42e7785b0d8c2d757885ff6e0be
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/257018
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
diff --git a/src/goInstallTools.ts b/src/goInstallTools.ts
index ff5cfe8..1ac3335 100644
--- a/src/goInstallTools.ts
+++ b/src/goInstallTools.ts
@@ -344,7 +344,7 @@
}
export function updateGoVarsFromConfig(): Promise<void> {
- const {binPath, why} = getBinPathWithExplanation('go', false);
+ const { binPath, why } = getBinPathWithExplanation('go', false);
const goRuntimePath = binPath;
logVerbose(`updateGoVarsFromConfig: found 'go' in ${goRuntimePath}`);
@@ -360,13 +360,19 @@
['env', 'GOPATH', 'GOROOT', 'GOPROXY', 'GOBIN', 'GOMODCACHE'],
{ env: toolExecutionEnvironment(), cwd: getWorkspaceFolderPath() },
(err, stdout, stderr) => {
- if (err || stderr) {
- outputChannel.append(`Failed to run '${goRuntimePath} env: ${err}\n${stderr}`);
+ if (err) {
+ outputChannel.append(`Failed to run '${goRuntimePath} env' : ${err}\n${stderr}`);
outputChannel.show();
vscode.window.showErrorMessage(`Failed to run '${goRuntimePath} env. The config change may not be applied correctly.`);
return reject();
}
+ if (stderr) {
+ // 'go env' may output warnings about potential misconfiguration.
+ // Show the messages to users but keep processing the stdout.
+ outputChannel.append(`'${goRuntimePath} env': ${stderr}`);
+ outputChannel.show();
+ }
logVerbose(`${goRuntimePath} env ...:\n${stdout}`);
const envOutput = stdout.split('\n');
if (!process.env['GOPATH'] && envOutput[0].trim()) {