Skip to content

Commit c705adf

Browse files
committed
src/goInstallTools: report go env failure
Fixes #555 Change-Id: I3b9f16079722f1b84580cdb6b8f2ee5427fc3530 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/253601 Reviewed-by: Suzy Mueller <[email protected]>
1 parent f2fd351 commit c705adf

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/goInstallTools.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import path = require('path');
1111
import { SemVer } from 'semver';
1212
import util = require('util');
1313
import vscode = require('vscode');
14-
import { toolInstallationEnvironment } from './goEnv';
14+
import { toolExecutionEnvironment, toolInstallationEnvironment } from './goEnv';
1515
import { addGoRuntimeBaseToPATH, initGoStatusBar } from './goEnvironmentStatus';
1616
import { getLanguageServerToolPath } from './goLanguageServer';
1717
import { restartLanguageServer } from './goMain';
@@ -32,6 +32,7 @@ import {
3232
getGoConfig,
3333
getGoVersion,
3434
getTempFilePath,
35+
getWorkspaceFolderPath,
3536
GoVersion,
3637
rmdirRecursive,
3738
} from './util';
@@ -350,8 +351,15 @@ export function updateGoVarsFromConfig(): Promise<void> {
350351
}
351352

352353
return new Promise<void>((resolve, reject) => {
353-
cp.execFile(goRuntimePath, ['env', 'GOPATH', 'GOROOT', 'GOPROXY', 'GOBIN', 'GOMODCACHE'], (err, stdout, stderr) => {
354-
if (err) {
354+
cp.execFile(goRuntimePath,
355+
['env', 'GOPATH', 'GOROOT', 'GOPROXY', 'GOBIN', 'GOMODCACHE'],
356+
{ env: toolExecutionEnvironment(), cwd: getWorkspaceFolderPath() },
357+
(err, stdout, stderr) => {
358+
if (err || stderr) {
359+
outputChannel.append(`Failed to run '${goRuntimePath} env: ${err}\n${stderr}`);
360+
outputChannel.show();
361+
362+
vscode.window.showErrorMessage(`Failed to run '${goRuntimePath} env. The config change may not be applied correctly.`);
355363
return reject();
356364
}
357365
const envOutput = stdout.split('\n');

0 commit comments

Comments
 (0)