src/pathUtils: check /usr/local/bin/go for go
This is a frequently used installation path for
custom executables including go in newer mac, but
this isn't included in system default PATH.
Many users add this in their login shell, or
/etc/paths.d, but when VSCode fails to load the
environment, the users end up with the incomplete
PATH, and go couldn't be found. Since this problem
got worsened recently, add /usr/local/bin/go to
the fallback path list.
For golang/vscode-go#971
Change-Id: Ie635b58c835189fbf1523c71cf4b6bac5e8400e3
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/276493
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
Trust: Suzy Mueller <suzmue@golang.org>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/src/utils/pathUtils.ts b/src/utils/pathUtils.ts
index 0b93650..235ca8b 100644
--- a/src/utils/pathUtils.ts
+++ b/src/utils/pathUtils.ts
@@ -98,12 +98,14 @@
return {binPath: pathFromPath, why: found('path')};
}
- // Check default path for go
+ // Check common paths for go
if (toolName === 'go') {
- const defaultPathForGo = process.platform === 'win32' ? 'C:\\Go\\bin\\go.exe' : '/usr/local/go/bin/go';
- if (executableFileExists(defaultPathForGo)) {
- binPathCache[toolName] = defaultPathForGo;
- return {binPath: defaultPathForGo, why: 'default'};
+ const defaultPathsForGo = process.platform === 'win32' ? ['C:\\Go\\bin\\go.exe'] : ['/usr/local/go/bin/go', '/usr/local/bin/go'];
+ for (const p of defaultPathsForGo) {
+ if (executableFileExists(p)) {
+ binPathCache[toolName] = p;
+ }
+ return {binPath: p, why: 'default'};
}
return {binPath: ''};
}