src/util,goInstallTools: log 'cwd'

Some users are experiencing ENOENT errors while running `go version` or
`go env` commands even though the go binary exists. Another reason that
users are experiencing the issue is `cwd` doesn't exist. Add extra logging
in the failure message to debug the issue.

For golang/vscode#774

Change-Id: I80ecc39b5e1a23f225eb914a87bd196e814acac0
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/263978
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 d4919f5..e250a45 100644
--- a/src/goInstallTools.ts
+++ b/src/goInstallTools.ts
@@ -367,7 +367,7 @@
 			{ env: toolExecutionEnvironment(), cwd: getWorkspaceFolderPath() },
 			(err, stdout, stderr) => {
 				if (err) {
-					outputChannel.append(`Failed to run '${goRuntimePath} env' : ${err}\n${stderr}`);
+					outputChannel.append(`Failed to run '${goRuntimePath} env' (cwd: ${getWorkspaceFolderPath()}): ${err}\n${stderr}`);
 					outputChannel.show();
 
 					vscode.window.showErrorMessage(`Failed to run '${goRuntimePath} env. The config change may not be applied correctly.`);
diff --git a/src/util.ts b/src/util.ts
index 083fcf9..9f9476c 100644
--- a/src/util.ts
+++ b/src/util.ts
@@ -348,11 +348,12 @@
 		}
 		warn(`cached Go version (${JSON.stringify(cachedGoVersion)}) is invalid, recomputing`);
 	}
+	const docUri = vscode.window.activeTextEditor?.document.uri;
+	const cwd = getWorkspaceFolderPath(docUri && docUri.fsPath.endsWith('.go') ? docUri : undefined);
+
 	let goVersion: GoVersion;
 	try {
 		const env = toolExecutionEnvironment();
-		const docUri = vscode.window.activeTextEditor?.document.uri;
-		const cwd = getWorkspaceFolderPath(docUri && docUri.fsPath.endsWith('.go') ? docUri : undefined);
 		const execFile = util.promisify(cp.execFile);
 		const { stdout, stderr } = await execFile(goRuntimePath, ['version'], { env, cwd });
 		if (stderr) {
@@ -361,7 +362,7 @@
 		}
 		goVersion = new GoVersion(goRuntimePath, stdout);
 	} catch (err) {
-		warn(`failed to run "${goRuntimePath} version": ${err}`);
+		warn(`failed to run "${goRuntimePath} version": ${err} cwd: ${cwd}`);
 		return;
 	}
 	if (!goBinPath) {  // if getGoVersion was called with a given goBinPath, don't cache the result.