Skip to content

Commit 47b9e02

Browse files
committed
src/goInstallTools: report when go.toolsManagement.go is not executable
When go.toolsManagement.go is not a valid executable, we forgot to log it. Instead, let `getGoVersion` throw an error so the later fallback logging kicks in. Moreover, if `go.logging.level` is error or more verbose, record the detailed error message in the console to help debugging. Fixes #2753 Change-Id: Icfb149779af3a1dc256cc11c931d1f29fb2b1a6a Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/501056 Reviewed-by: Suzy Mueller <[email protected]> Run-TryBot: Hyang-Ah Hana Kim <[email protected]> TryBot-Result: kokoro <[email protected]>
1 parent 50e2b64 commit 47b9e02

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/goInstallTools.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { ConfigurationTarget } from 'vscode';
1616
import { extensionInfo, getGoConfig, getGoplsConfig } from './config';
1717
import { toolExecutionEnvironment, toolInstallationEnvironment } from './goEnv';
1818
import { addGoRuntimeBaseToPATH, clearGoRuntimeBaseFromPATH } from './goEnvironmentStatus';
19-
import { logVerbose } from './goLogging';
19+
import { logVerbose, logError } from './goLogging';
2020
import { GoExtensionContext } from './context';
2121
import { addGoStatus, initGoStatusBar, outputChannel, removeGoStatus } from './goStatus';
2222
import {
@@ -108,16 +108,17 @@ export async function getGoForInstall(goVersion: GoVersion, silent?: boolean): P
108108
if (!configured) {
109109
return goVersion;
110110
}
111-
if (executableFileExists(configured)) {
112-
try {
113-
const go = await getGoVersion(configured);
114-
if (go) return go;
115-
} finally {
116-
if (!silent) {
117-
outputChannel.appendLine(
118-
`Ignoring misconfigured 'go.toolsManagement.go' (${configured}). Provide a valid Go command.`
119-
);
120-
}
111+
112+
try {
113+
const go = await getGoVersion(configured);
114+
if (go) return go;
115+
} catch (e) {
116+
logError(`getGoForInstall failed to run 'go version' with the configured go for tool install: ${e}`);
117+
} finally {
118+
if (!silent) {
119+
outputChannel.appendLine(
120+
`Ignoring misconfigured 'go.toolsManagement.go' (${configured}). Provide a valid path to the Go command.`
121+
);
121122
}
122123
}
123124

0 commit comments

Comments
 (0)