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

x/tools/gopls: symbol definitions not found after latest vscode/gopls upgrade #66677

Closed
eliben opened this issue Apr 4, 2024 · 7 comments
Closed
Assignees
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@eliben
Copy link
Member

eliben commented Apr 4, 2024

What did you do?

Clone a github repo, e.g. https://github.com/eliben/gemini-cli

$ cd gemini-cli
$ code .

Navigate to main.go and click "Go to definition" on the Execute symbol on line 10

What did you expect to see?

Expected to jump to definition.

What did you see instead?

"No definition found for Execute" popup

Build info

golang.org/x/tools/gopls v0.15.2
    golang.org/x/tools/[email protected] h1:4JKt4inO8JaFW3l/Fh9X1k/5JQn+iUOpdc4/Lpi0mOs=
    github.com/BurntSushi/[email protected] h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
    github.com/google/[email protected] h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
    golang.org/x/exp/[email protected] h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
    golang.org/x/[email protected] h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
    golang.org/x/[email protected] h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
    golang.org/x/[email protected] h1:vcVnuftN4J4UKLRcgetjzfU9FjjgXUUYUc3JhFplgV4=
    golang.org/x/[email protected] h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
    golang.org/x/[email protected] h1:No0LMXYFkp3j4oEsPdtY8LUQz33gu79Rm9DE+izMeGQ=
    golang.org/x/[email protected] h1:KUas02EjQK5LTuIx1OylBQdKKZ9jeugs+HiqO5HormU=
    honnef.co/go/[email protected] h1:oFEHCKeID7to/3autwsWfnuv69j3NsfcXbvJKuIcep8=
    mvdan.cc/[email protected] h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo=
    mvdan.cc/xurls/[email protected] h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
go: go1.21.1

This happened today, after an auto-upgrade of vscode.

$ code --version
1.87.2
863d2581ecda6849923a2118d93a088b0745d9d6
x64

I don't see errors in the gopls (server) in the Output terminal. Extension Host terminal says:

2024-04-04 06:36:26.948 [info] ExtensionService#_doActivateExtension golang.go, startup: false, activationEvent: 'onLanguage:go'
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Apr 4, 2024
@gopherbot gopherbot added this to the Unreleased milestone Apr 4, 2024
@findleyr
Copy link
Contributor

findleyr commented Apr 4, 2024

Hi Eli, thanks for filing.

I can reproduce this by installing gopls with go 1.21, and it is fixed by installing gopls with go 1.22. I believe VS Code should have prompted to reinstall tools upon the version mismatch, but it didn't, for me (CC @hyangah).

I'm haven't yet investigated the failure mode, which is rather disconcerting: no errors, just a broken experience.

@findleyr findleyr modified the milestones: Unreleased, gopls/v0.15.3 Apr 4, 2024
@findleyr
Copy link
Contributor

findleyr commented Apr 4, 2024

This is a manifestation of #66525: (1) go/types fails fast with an error when the language version is newer than its runtime version, and (2) this error is not reported through the error handler, therefore not seen by gopls. Hence the silent brokenness of your workspace: go list happily lists packages and gopls happily type checks them, but they are empty.

We need to guard against this when built with 1.21.x, since this is a very bad failure mode. We should capture a synthetic type checking diagnostic, and unset types.Config.GoVersion to proceed with type checking.

@findleyr findleyr self-assigned this Apr 4, 2024
@eliben
Copy link
Member Author

eliben commented Apr 4, 2024

Thanks for the quick response, @findleyr

Indeed, removing gopls and re-installing it with 1.22 solved the issue for me.

@hyangah
Copy link
Contributor

hyangah commented Apr 4, 2024

@findleyr About the prompt for tools update not showing up - do you happen to have 'go.toolsManagement.autoUpdate' set? I just tested it with the default setting ("go.toolsManagement.autoUpdate": false) and got the following prompt.
Screenshot 2024-04-04 at 4 13 52 PM

If the setting is 'true', the extension tries to rebuild and restart gopls without prompt, but, sadly, due to the issue like golang/vscode-go#3168, go install runs with the system version of go (in this case 1.21.x). :-(

@findleyr
Copy link
Contributor

findleyr commented Apr 4, 2024

@hyangah -- I'm sorry: I just tried again and got the popup (but it went away after ~10s). I must have missed it.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/576678 mentions this issue: internal/check: filter out too-new Go versions for type checking

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/577302 mentions this issue: [gopls-release-branch.0.15] internal/check: filter out too-new Go versions for type checking

gopherbot pushed a commit to golang/tools that referenced this issue Apr 8, 2024
…sions for type checking

NOTE: Patched for the release branch to use versions.Compare rather than
versions.Before.

The type checker produces an error if the Go version is too new. When
compiled with Go 1.21, this error is silently dropped on the floor and
the type checked package is empty, due to golang/go##66525.

Guard against this very problematic failure mode by filtering out Go
versions that are too new. We should also produce a diagnostic, but that
is more complicated and covered by golang/go#61673.

Also: fix a bug where sandbox cleanup would fail due to being run with a
non-local toolchain.

Updates golang/go#66677
Updates golang/go#66730

Change-Id: Ia66f17c195382c9c55cf0ef883e898553ce950e3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/576678
Reviewed-by: Alan Donovan <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
(cherry picked from commit de6db98)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/577302
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants