src/goInstallTools: report `go env` failure

Fixes golang/vscode-go#555

Change-Id: I3b9f16079722f1b84580cdb6b8f2ee5427fc3530
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/253601
Reviewed-by: Suzy Mueller <suzmue@golang.org>
diff --git a/src/goInstallTools.ts b/src/goInstallTools.ts
index 56de8c9..218b58e 100644
--- a/src/goInstallTools.ts
+++ b/src/goInstallTools.ts
@@ -11,7 +11,7 @@
 import { SemVer } from 'semver';
 import util = require('util');
 import vscode = require('vscode');
-import { toolInstallationEnvironment } from './goEnv';
+import { toolExecutionEnvironment, toolInstallationEnvironment } from './goEnv';
 import { addGoRuntimeBaseToPATH, initGoStatusBar } from './goEnvironmentStatus';
 import { getLanguageServerToolPath } from './goLanguageServer';
 import { restartLanguageServer } from './goMain';
@@ -32,6 +32,7 @@
 	getGoConfig,
 	getGoVersion,
 	getTempFilePath,
+	getWorkspaceFolderPath,
 	GoVersion,
 	rmdirRecursive,
 } from './util';
@@ -350,8 +351,15 @@
 	}
 
 	return new Promise<void>((resolve, reject) => {
-		cp.execFile(goRuntimePath, ['env', 'GOPATH', 'GOROOT', 'GOPROXY', 'GOBIN', 'GOMODCACHE'], (err, stdout, stderr) => {
-			if (err) {
+		cp.execFile(goRuntimePath,
+			['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}`);
+				outputChannel.show();
+
+				vscode.window.showErrorMessage(`Failed to run '${goRuntimePath} env. The config change may not be applied correctly.`);
 				return reject();
 			}
 			const envOutput = stdout.split('\n');