vscode: VS Code unable to locate Go tools on my MacBook
-
VSCode Version: Version: 1.49.3 Commit: 2af051012b66169dde0c4dfae3f5ef48f787ff69 Date: 2020-10-02T17:54:06.165Z Electron: 9.2.1 Chrome: 83.0.4103.122 Node.js: 12.14.1 V8: 8.3.110.13-electron.0
-
OS Version: Darwin x64 18.7.0
-
Go Extension Version: 0.17.2
Steps to Reproduce:
- Close all VS Code windows
- Launch VS Code by clicking on a pinned shortcut in the Dock
I get the error below:
While troubleshooting locally, I used the Go: Locate Configured Go Tools command from the Go Extension and it showed the following:
Checking configured tools....
GOBIN: undefined
toolsGopath: undefined
gopath: undefined
GOROOT:
PATH: /usr/bin:/bin:/usr/sbin:/sbin
unable to locate "go" binary in GOROOT () or PATH (/usr/bin:/bin:/usr/sbin:/sbin)
unable to locate "go" binary in GOROOT () or PATH (/usr/bin:/bin:/usr/sbin:/sbin)
When I launch VS Code by running code
from a terminal session the error message does not occur and the Go: Locate Configured Go Tools command correctly finds the Go tools.
Checking configured tools....
GOBIN: undefined
toolsGopath:
gopath: /Users/dbourque/dev/golang
GOROOT: /usr/local/Cellar/go/1.15.2/libexec
PATH: [redacted]
gocode: /Users/dbourque/dev/golang/bin/gocode installed
gopkgs: /Users/dbourque/dev/golang/bin/gopkgs installed
go-outline: /Users/dbourque/dev/golang/bin/go-outline installed
go-symbols: /Users/dbourque/dev/golang/bin/go-symbols installed
guru: /Users/dbourque/dev/golang/bin/guru installed
gorename: /Users/dbourque/dev/golang/bin/gorename installed
gotests: /Users/dbourque/dev/golang/bin/gotests installed
gomodifytags: /Users/dbourque/dev/golang/bin/gomodifytags installed
impl: /Users/dbourque/dev/golang/bin/impl installed
fillstruct: /Users/dbourque/dev/golang/bin/fillstruct installed
goplay: /Users/dbourque/dev/golang/bin/goplay installed
godoctor: /Users/dbourque/dev/golang/bin/godoctor installed
dlv: /Users/dbourque/dev/golang/bin/dlv installed
gocode-gomod: /Users/dbourque/dev/golang/bin/gocode-gomod installed
godef: /Users/dbourque/dev/golang/bin/godef installed
goimports: /Users/dbourque/dev/golang/bin/goimports installed
golangci-lint: /Users/dbourque/dev/golang/bin/golangci-lint installed
gopls: /Users/dbourque/dev/golang/bin/gopls installed
go env
Workspace Folder (tryitout): /Users/dbourque/dev/tryitout
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/dbourque/Library/Caches/go-build"
GOENV="/Users/dbourque/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/dbourque/dev/golang/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/dbourque/dev/golang"
GOPRIVATE=""
GOPROXY=""
GOROOT="/usr/local/Cellar/go/1.15.2/libexec"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.15.2/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/dbourque/dev/tryitout/go.mod"
CGO_CFLAGS=""
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="/usr/local/bin/pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/3t/4048hqr5459dw83ksmkqxn7r0000gn/T/go-build186798659=/tmp/go-build -gno-record-gcc-switches -fno-common"
Does this issue occur when all extensions are disabled?: No
This issue for the Go Extension generated the same error message but this fix for it does not correct the behavior for me.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 23 (3 by maintainers)
No worries @CanRau , I stole the idea from the depths of another github issue thread and have to do the same for all of my windows. Luckily not all of them need the full environment!
Running
Developer: reload window
fixed it for me. Seems they reduced the timeout for loading the environment from 10s to 3s.@CanRau Of course that’s because the extension is also checking
GOROOT/bin
in addition toPATH
etc. But what @dylan-bourque is getting at is about why the go extension isn’t seeing theprocess.env['PATH']
it should see. I suspect a race between go extension’s initialization and environment variable setup for extension host. Can we focus on the issue?Re: why setting
GOROOT
is not recommended - if yourGOROOT
doesn’t match what thego
command thinks it should be, that can lead to other various issues. So, except a few cases where a differentGOROOT
is necessary, it’s better to let thego
command figure it out.I am still not convinced that this is a VS Code issue