Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reevaluate the need for tools reinstallations when GOROOT is changed #294

Closed
5 of 25 tasks
hyangah opened this issue Jul 6, 2020 · 4 comments
Closed
5 of 25 tasks

Comments

@hyangah
Copy link
Contributor

hyangah commented Jul 6, 2020

This extension keeps track of the GOROOT used last time in ctx.globalState.get('toolsGoInfo').
If use of a different GOROOT is detected when activated, it prompts users to recompile/reinstall Go tools with a message like:

Your current goroot (${currentGoroot}) is different than before (${prevGoroot}), a few Go tools may need recompiling

The code is here

vscode-go/src/goMain.ts

Lines 94 to 127 in 89c61d9

if (prevGoroot && prevGoroot.toLowerCase() !== currentGoroot) {
vscode.window
.showInformationMessage(
`Your current goroot (${currentGoroot}) is different than before (${prevGoroot}), a few Go tools may need recompiling`,
updateToolsCmdText
)
.then((selected) => {
if (selected === updateToolsCmdText) {
installAllTools(true);
}
});
} else {
const currentVersion = await getGoVersion();
if (currentVersion) {
const prevVersion = toolsGoInfo[toolsGopath].version;
const currVersionString = currentVersion.format();
if (prevVersion !== currVersionString) {
if (prevVersion) {
vscode.window
.showInformationMessage(
'Your Go version is different than before, a few Go tools may need re-compiling',
updateToolsCmdText
)
.then((selected) => {
if (selected === updateToolsCmdText) {
installAllTools(true);
}
});
}
toolsGoInfo[toolsGopath].version = currVersionString;
}
}
}

This was a heuristic to deal with old tools that used the GOROOT embedded during the tool's compile time (See microsoft/vscode-go#1286 for example) in old days. Newer tools shouldn't depend on the value of GOROOT used in the tool's compile time, so recompiling shouldn't be necessary as long as the tool is up-to-date.

Examine tools this extension depends on and check whether they use hard-coded build time GOROOT.
Once we know no tools require recompilation any more, remove this popup and the heuristic.

Inspection status (check if investigated && not require recompilation)

  • gocode
  • gocode-gomod
  • gopkgs: uses build.Default.GOROOT, requires to set the GOROOT env var.
  • go-outline
  • go-symbols
  • guru
  • gorename
  • gomodifytags
  • goplay
  • impl
  • gotype-live
  • godef: works, but requires to set the GOROOT env var.
  • gogetdoc
  • goimports
  • goreturns
  • goformat
  • golint
  • gotests
  • staticcheck: no issue with the latest version.
  • golangci-lint
  • revive
  • gopls
  • dlv
  • fillstruct
  • godoctor

cc @stamblerre @mcjcloud @FiloSottile

@gopherbot
Copy link
Collaborator

Change https://golang.org/cl/244758 mentions this issue: src/goDeclaration.ts: godef requires the right GOROOT env var

gopherbot pushed a commit that referenced this issue Jul 24, 2020
It uses runtime.GOROOT() to clean file names. If the version of
Go used to build the godef tool is different from the version of
Go we are currently using is different, it will not know the
right place for standard libraries without GOROOT env var.

Updates #294
Updates #146

Change-Id: I4b93023634d4f20b4e9802f756e168e41c1055f0
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/244758
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
hyangah added a commit to hyangah/vscode-go that referenced this issue Jul 24, 2020
It uses runtime.GOROOT() to clean file names. If the version of
Go used to build the godef tool is different from the version of
Go we are currently using is different, it will not know the
right place for standard libraries without GOROOT env var.

Updates golang#294
Updates golang#146

Change-Id: I4b93023634d4f20b4e9802f756e168e41c1055f0
@hyangah hyangah added this to the Backlog milestone Aug 7, 2020
@hyangah
Copy link
Contributor Author

hyangah commented Aug 20, 2020

A user reported gocode (or gocode-gomod) needed to be reinstalled when go is updated. (#552) Need to verify it.

@gopherbot
Copy link
Collaborator

Change https://golang.org/cl/254137 mentions this issue: src/goPackages.ts: pass GOROOT to gopkgs

gopherbot pushed a commit that referenced this issue Sep 11, 2020
gopkgs uses build.Default.GOROOT
so `GOROOT` env var should be set to use `gopkgs` compiled with
a different version of Go.

Updates #294

Change-Id: I746baed9fcf692a6c9248cdfd17f8ca3fef19426
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/254137
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
@hyangah
Copy link
Contributor Author

hyangah commented Apr 15, 2022

The mentioned code that tracks GOROOT change was deleted. Instead, the extension currently checks go version output and compares the tools' build info (go version -m) since v0.32.0 So, I'd say this issue is no longer relevant.
Closing this issue.

@hyangah hyangah closed this as completed Apr 15, 2022
@golang golang locked and limited conversation to collaborators Apr 15, 2023
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

2 participants