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: incorrectly detecting go version #56465

Closed
hyangah opened this issue Oct 28, 2022 · 3 comments
Closed

x/tools/gopls: incorrectly detecting go version #56465

hyangah opened this issue Oct 28, 2022 · 3 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@hyangah
Copy link
Contributor

hyangah commented Oct 28, 2022

I just got this prompt when running a vscode-go integration test with v0.10.0-pre.3.

Screen Shot 2022-10-27 at 10 33 02 PM

The log message I got:

[Trace - 10:25:39 PM] Received response 'initialize - (0)' in 58ms.
Result: {
    ...
    "serverInfo": {
        "name": "gopls",
        "version": "{\"GoVersion\":\"go1.19.1\",\"Path\":\"golang.org/x/tools/gopls\",\"Main\":{\"Path\":\"golang.org/x/tools/gopls\",\"Version\":\"v0.10.0-pre.3\",... \"Replace\":null}...\"Version\":\"v0.10.0\"}"
    }
}

[Trace - 10:25:39 PM] Sending notification 'initialized'.
Params: {}
[Trace - 10:25:39 PM] Received notification 'window/showMessage'.
Params: {
    "type": 1,
    "message": "Found Go version 1.-1, which is not supported by this version of gopls. Please upgrade to Go 1.16 or later and reinstall gopls. If you can't upgrade and want this message to go away, please install gopls v0.7.5. See https://go.dev/s/gopls-support-policy for more details."
}
[Trace - 10:25:39 PM] Received request 'client/registerCapability - (1)'.
...
[Trace - 10:25:39 PM] Sending response 'client/registerCapability - (1)'. Processing request took 0ms
...
[Trace - 10:25:40 PM] Received request 'workspace/configuration - (3)'.
Params: {
    "items": [
        {
            "scopeUri": "file:///Users/hakim/projects/vscode-go/test/testdata/gogetdocTestData",
            "section": "gopls"
        }
    ]
}
[Trace - 10:25:40 PM] Sending response 'workspace/configuration - (3)'. Processing request took 2ms
Result: [
    {
        "ui.semanticTokens": true,
        "ui.codelenses": {
            "run_vulncheck_exp": true
        },
        "ui.inlayhint.hints": {
            "assignVariableTypes": false,
            "compositeLiteralFields": false,
            "compositeLiteralTypes": false,
            "constantValues": false,
            "functionTypeParameters": false,
            "parameterNames": true,
            "rangeVariableTypes": false
        },
        "allExperiments": true
    }
]

[Info  - 10:25:40 PM] 2022/10/27 22:25:40 go env for /Users/hakim/projects/vscode-go/test/testdata/gogetdocTestData
(root /Users/hakim/projects/vscode-go/test/testdata/gogetdocTestData)
(go version go version go1.19.2 darwin/amd64)
(valid build configuration = true)
(build flags: [])
GOMOD=/Users/hakim/projects/vscode-go/test/testdata/gogetdocTestData/go.mod
GOFLAGS=
GONOPROXY=
GOROOT=/usr/local/Cellar/go/1.19.2/libexec
...

I don't know how I ended up with -1 as my go version. Can be related to some peculiarity in the test setup.
According to the later info message (go env ...), it looks like gopls found go version correctly though.

cc @findleyr

@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 Oct 28, 2022
@gopherbot gopherbot added this to the Unreleased milestone Oct 28, 2022
@hyangah hyangah modified the milestones: Unreleased, gopls/v0.10.0 Oct 28, 2022
@hyangah hyangah added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 28, 2022
@hyangah hyangah modified the milestones: gopls/v0.10.0, gopls/v0.10.1 Oct 28, 2022
@findleyr
Copy link
Contributor

Thanks for catching this. https://go.dev/cl/445581 inadvertently removed handling for an undetected Go version.

Is it possible that in your test setup the go version would only be resolved after a didChangeConfiguration request?

@findleyr findleyr modified the milestones: gopls/v0.10.1, gopls/v0.10.0 Oct 28, 2022
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/446175 mentions this issue: gopls/internal: don't show a warning if the Go version is undetected

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/446235 mentions this issue: [gopls-release-branch.0.10] gopls/internal: don't show a warning if the Go version is undetected

gopherbot pushed a commit to golang/tools that referenced this issue Oct 28, 2022
…he Go version is undetected

CL 445581 inadvertently removed suppression of the Go version error if
the Go version was undetected. Add it back, with a test.

Fixes golang/go#56465

Change-Id: I352369096280c8d3423a7345123ec9309359fb58
Reviewed-on: https://go-review.googlesource.com/c/tools/+/446175
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
(cherry picked from commit d62bb0ee81c0fdecd166cad1f91e3f61204b0640)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/446235
@golang golang locked and limited conversation to collaborators Oct 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants