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: panic: invalid Go version "go1.22.1" (should be something like "go1.12") #66553

Open
tvendelin opened this issue Mar 27, 2024 · 5 comments
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@tvendelin
Copy link

gopls version

golang.org/x/tools/gopls v0.15.2

go env

$ go env
GO111MODULE='on'
GOARCH='arm64'
GOBIN='/Users/tovendelin/go/bin'
GOCACHE='/Users/tovendelin/Library/Caches/go-build'
GOENV='/Users/tovendelin/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/tovendelin/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/tovendelin/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.1'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/gc/lskw2x194gb3t26j37m53h_80000gp/T/go-build1500935195=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

mkdir $GOPATH/src/foo
go mod init
nvim bar.go

What did you see happen?

Error detected while processing CursorHold Autocommands for "<buffer=1>"..function go#lsp#DidChange[25]..12[43]..15:
line   11:
E900: Invalid channel id
Press ENTER or type command to continue

What did you expect to see?

vim-go: finished loading packages

If I edit go.mod and remove the patch number from the version (1.22.1 to 1.22 in my case), then it works without errors. This relates, I think, to the closed issue golang/vscode-go#3276

Editor and settings

Neovim
$ nvim --version
NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1703358377

Config: https://github.com/tvendelin/nvim

Logs

[ERROR][2024-03-27 07:46:19] .../vim/lsp/rpc.lua:734    "rpc"   "/Users/myusername/.local/share/nvim/mason/bin/gopls"   "stderr"        'panic: invalid Go version "go1.22.1" (should be something like "go1.12")\n\ngoroutine 1010 [running]:\n'
[ERROR][2024-03-27 07:46:19] .../vim/lsp/rpc.lua:734    "rpc"   "/Users/myusername/.local/share/nvim/mason/bin/gopls"   "stderr"        "go/types.NewChecker(0x14000735a88?, 0x14000f3ac40, 0x14001411f90, 0x0?)\n\t/usr/local/go/src/go/types/check.go:237 +0x1ec\ngolang.org/x/tools/gopls/internal/cache.(*analysisNode).typeCheck(0x14000795550, {0x14000dfa1e0, 0x3, 0x3})\n\t/Users/myusername/go/pkg/mod/golang.org/x/tools/gopls@v0.15.2/internal/cache/analysis.go:1028 +0x5d8\ngolang.org/x/tools/gopls/internal/cac
he.(*analysisNode).run(0x14000795550, {0x103802758?, 0x140013d0ff0})\n\t/Users/myusername/go/pkg/mod/golang.org/x/tools/gopls@v0.15.2/internal/cache/analysis.go:810 +0x1c8\ngolang.org/x/tools/gopls/internal/cache.(*analysisNode).runCached(0x14000795550, {0x103802758?, 0x140013d0ff0})\n\t/Users/myusername/go/pkg/mod/golang.org/x/tools/gopls@v0.15.2/internal/cache/analysis.go:672 +0x104\n"
[ERROR][2024-03-27 07:46:19] .../vim/lsp/rpc.lua:734    "rpc"   "/Users/myusername/.local/share/nvim/mason/bin/gopls"   "stderr"        "golang.org/x/tools/gopls/internal/cache.(*Snapshot).Analyze.func6.1()\n\t/Users/myusername/go/pkg/mod/golang.org/x/tools/gopls@v0.15.2/internal/cache/analysis.go:398 +0xa4\ngolang.org/x/sync/errgroup.(*Group).Go.func1()\n\t/Users/myusername/go/pkg/mod/golang.org/x/sync@v0.6.0/errgroup/errgroup.go:78 +0x5c\ncreated by golang.org/x/sync/errgroup.(*Group).Go\n\t/Users/toven
delin/go/pkg/mod/golang.org/x/sync@v0.6.0/errgroup/errgroup.go:75 +0x9c\n"
@tvendelin tvendelin added gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. labels Mar 27, 2024
@gopherbot gopherbot added this to the Unreleased milestone Mar 27, 2024
@suzmue
Copy link
Contributor

suzmue commented Mar 27, 2024

@tvendelin Thanks for the bug! I see that you are using go1.22.1 which I think should not have this issue. Can you check what version of go gopls is built with by running $ gopls -v version? Thank you!

I am trying to investigate why this issue is coming up so frequently in the last week, what changed that made you encounter this issue now? Did you recently update go versions?

@suzmue suzmue added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Mar 27, 2024
@tvendelin
Copy link
Author

@suzmue "Waiting for info"?

Your question is already answered in my bug report. I've also described a workaround. From what I see, a go.mod generated by go mod init disagree with gopls about the version format.

@seankhliao
Copy link
Member

we asked for the output of a specific command, which you have not provided.

@seankhliao seankhliao added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Mar 28, 2024
@suzmue
Copy link
Contributor

suzmue commented Mar 28, 2024

Assuming that the gopls you are running was built with an older go version, you will need to rebuild gopls with go1.21 or newer:

$ go install golang.org/x/tools/gopls@latest

You can verify that gopls has the new version by:

$ gopls -v version
Build info
----------
golang.org/x/tools/gopls v0.15.2
    golang.org/x/tools/gopls@v0.15.2 h1:4JKt4inO8JaFW3l/Fh9X1k/5JQn+iUOpdc4/Lpi0mOs=
    github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
    github.com/google/go-cmp@v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
    golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
    golang.org/x/mod@v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
    golang.org/x/sync@v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
    golang.org/x/telemetry@v0.0.0-20240209200032-7b892fcb8a78 h1:vcVnuftN4J4UKLRcgetjzfU9FjjgXUUYUc3JhFplgV4=
    golang.org/x/text@v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
    golang.org/x/tools@v0.18.1-0.20240311201521-78fbdeb61842 h1:No0LMXYFkp3j4oEsPdtY8LUQz33gu79Rm9DE+izMeGQ=
    golang.org/x/vuln@v1.0.1 h1:KUas02EjQK5LTuIx1OylBQdKKZ9jeugs+HiqO5HormU=
    honnef.co/go/tools@v0.4.6 h1:oFEHCKeID7to/3autwsWfnuv69j3NsfcXbvJKuIcep8=
    mvdan.cc/gofumpt@v0.6.0 h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo=
    mvdan.cc/xurls/v2@v2.5.0 h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
go: go1.21.5

@suzmue suzmue added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Mar 28, 2024
@randomgithubuser1
Copy link

randomgithubuser1 commented Apr 1, 2024

I'm also seeing this issue. Trying to set up nvim LSP with gopls.

[ERROR][2024-04-01 15:03:09] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/user/.local/share/nvim/mason/bin/gopls"	"stderr"	'panic: invalid Go version "go1.21.3" (should be something like "go1.12")\n\ngoroutine 2651 [running]:\ngo/types.NewChecker(0x0'
$ go version
go version go1.22.1 darwin/amd64
$ gopls -v version
Build info
----------
golang.org/x/tools/gopls v0.15.2
    golang.org/x/tools/gopls@v0.15.2 h1:4JKt4inO8JaFW3l/Fh9X1k/5JQn+iUOpdc4/Lpi0mOs=
    github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
    github.com/google/go-cmp@v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
    golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
    golang.org/x/mod@v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
    golang.org/x/sync@v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
    golang.org/x/telemetry@v0.0.0-20240209200032-7b892fcb8a78 h1:vcVnuftN4J4UKLRcgetjzfU9FjjgXUUYUc3JhFplgV4=
    golang.org/x/text@v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
    golang.org/x/tools@v0.18.1-0.20240311201521-78fbdeb61842 h1:No0LMXYFkp3j4oEsPdtY8LUQz33gu79Rm9DE+izMeGQ=
    golang.org/x/vuln@v1.0.1 h1:KUas02EjQK5LTuIx1OylBQdKKZ9jeugs+HiqO5HormU=
    honnef.co/go/tools@v0.4.6 h1:oFEHCKeID7to/3autwsWfnuv69j3NsfcXbvJKuIcep8=
    mvdan.cc/gofumpt@v0.6.0 h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo=
    mvdan.cc/xurls/v2@v2.5.0 h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
go: go1.22.1

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. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants