-
Notifications
You must be signed in to change notification settings - Fork 645
Reinstall tools when a GOROOT change is detected #1286
Comments
We do this currently if we see a change in the version of Go being used. |
That's an approximation, since the tools will break on a GOROOT change even if the version stays the same, but it would have helped in my case. However, it did not rebuild the tools automatically. How/when is it supposed to happen? |
The first time you open a VS Code window after changing the Go version, VS Code would give you a prompt saying "Your Go version is different than before, few Go tools may need re-compiling" and an option to update all the dependent tools. Behind the scenes, we store the Go version being used in local storage. Whenever you open a new window or Go project, the Go version is checked |
I personally don't get the "Your Go version is different than before, few Go tools may need re-compiling" message. (Just updated to When attempting to run a Go To Def: [Extension Host] Error: Command failed: /Users/dylan/bin/godef -t -i -f /Users/dylan/src/github.com/.../path.go -o 681
godef: no declaration found for ioutil.TempFile
at ChildProcess.exithandler (child_process.js:217:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:194:7)
at maybeClose (internal/child_process.js:899:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5) |
I never saw it either. It might be that some people, me included,
restart the editor so rarely that the check is not effective if only
done at startup.
|
FWIW, I just updated Go changing the GOROOT, and even restarting the editor no message popped up. I had to delete the tools and reinstall them to get back functional autocomplete for the stdlib. (A change of version without a change of GOROOT would cause more subtle problems I suspect.) |
Thanks so much for this @ramya-rao-a 🎉 |
The feature will be out in the next update to the Go extension |
This feature is now out in the latest update of the Go extension (0.6.70) |
When the GOROOT changes (for example when Go is updated on macOS with Homebrew) the old GOROOT stays embedded in the binaries built with the old toolchain. This causes all kinds of things to break: list packages, autocomplete,
autocompleteUnimportedPackages
all break for stdlib packages.This is the scenario explained here: https://blog.filippo.io/stale-goroot-and-gorebuild/
Ideally, the extension should detect this and rebuild the tools, also because the Go version changed, so it's probably time to rebuild code analysis tools. Otherwise, it should explicitly set the
GOROOT
env var to the output ofgo env GOROOT
.Similar to fatih/vim-go#901
The text was updated successfully, but these errors were encountered: