Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Reinstall tools when a GOROOT change is detected #1286

Closed
FiloSottile opened this issue Oct 16, 2017 · 9 comments
Closed

Reinstall tools when a GOROOT change is detected #1286

FiloSottile opened this issue Oct 16, 2017 · 9 comments

Comments

@FiloSottile
Copy link
Contributor

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 of go env GOROOT.

Similar to fatih/vim-go#901

@ramya-rao-a
Copy link
Contributor

We do this currently if we see a change in the version of Go being used.
Doesnt that help?

@FiloSottile
Copy link
Contributor Author

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?

@ramya-rao-a
Copy link
Contributor

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

@arbourd
Copy link
Contributor

arbourd commented Oct 26, 2017

I personally don't get the "Your Go version is different than before, few Go tools may need re-compiling" message. (Just updated to 1.9.2 with Homebrew and am running into this issue)

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)

@FiloSottile
Copy link
Contributor Author

FiloSottile commented Oct 27, 2017 via email

@FiloSottile
Copy link
Contributor Author

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.)

@arbourd
Copy link
Contributor

arbourd commented Dec 5, 2017

Thanks so much for this @ramya-rao-a 🎉

@ramya-rao-a
Copy link
Contributor

The feature will be out in the next update to the Go extension

@ramya-rao-a
Copy link
Contributor

This feature is now out in the latest update of the Go extension (0.6.70)

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants