vscode-go icon indicating copy to clipboard operation
vscode-go copied to clipboard

extension crashes if `go.mod` uses language version and the local go version is older than the go version in `go.mod`

Open hyangah opened this issue 1 year ago • 12 comments

Repro case:

$ GOTOOLCHAIN=local go version
go1.21.9
$ cat go.mod
module w

go 1.22

Screenshot 2024-04-05 at 3 41 23 PM

Failed to run '/usr/local/go/bin/go env' (cwd: /Users/hakim/projects/go-qrcode): Error: Command failed: /usr/local/go/bin/go env -json GOPATH GOROOT GOPROXY GOBIN GOMODCACHE
go: downloading go1.22 (darwin/amd64)
go: download go1.22 for darwin/amd64: toolchain not available

go: downloading go1.22 (darwin/amd64)
go: download go1.22 for darwin/amd64: toolchain not available

The root cause is https://github.com/golang/go/issues/65580 that was closed as a duplicate of https://github.com/golang/go/issues/62278, which was closed in favor of a better error message.

cc @golang/tools-team

hyangah avatar Apr 05 '24 19:04 hyangah

I'm seeing a similar problem, but go.work instead of go.mod. I believe the underlying problem to be the same.

Error loading workspace: packages.Load error: err: exit status 1: stderr: go: go.work requires go >= 1.22.3 (running go 1.22.2)

Running go version on the integrated terminal gives:

go version go1.22.3 linux/amd64

Thus the go1.22.2 toolchain was able to download and use the go1.22.3 toolchain, but gopls doesn't pick it up.

rhcarvalho avatar May 28 '24 14:05 rhcarvalho

@hyangah We expect this to be fixed once 1.21.11 is released with the backported change to download 1.22.0 when 1.22 is listed in go.mod, right?

matloob avatar May 28 '24 17:05 matloob