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

cmd/go: go toolchain version switch doesn't work when only language version is set in go.mod #65580

Closed
hyangah opened this issue Feb 7, 2024 · 4 comments

Comments

@hyangah
Copy link
Contributor

hyangah commented Feb 7, 2024

Go version

go 1.21.4

Output of go env in your module/workspace:

$ GOTOOLCHAIN=auto go env
go: downloading go1.22 (darwin/amd64)
go: download go1.22 for darwin/amd64: toolchain not available

What did you do?

Had a project created with a go built from tip during 1.22 dev cycle.
The go.mod file has language version, but not toolchain version yet.

$ cat go.mod
module example.com/bug

go 1.22

What did you see happen?

Since go1.22.0 is released, I expected the go command to pick up go1.22.0 when version switching is needed.
Instead, most go commands failed in the module since there is no toolchain named go1.22.

What did you expect to see?

~/bug$ go version
go version go1.21.4 darwin/amd64
~/bug$ GOTOOLCHAIN=auto go env
go: downloading go1.22 (darwin/amd64)
go: download go1.22 for darwin/amd64: toolchain not available
~/bug$ GOTOOLCHAIN=auto go version
go: downloading go1.22 (darwin/amd64)
go: download go1.22 for darwin/amd64: toolchain not available
~/bug$ GOTOOLCHAIN=auto go mod tidy
go: downloading go1.22 (darwin/amd64)
go: download go1.22 for darwin/amd64: toolchain not available
~/bug$ GOTOOLCHAIN=auto go mod tidy -go=1.21.4
go: downloading go1.22 (darwin/amd64)
go: download go1.22 for darwin/amd64: toolchain not available
~/bug$ GOTOOLCHAIN=auto go get go@latest
go: downloading go1.22 (darwin/amd64)
go: download go1.22 for darwin/amd64: toolchain not available
~/bug$ GOTOOLCHAIN=auto go get toolchain@latest
go: downloading go1.22 (darwin/amd64)
go: download go1.22 for darwin/amd64: toolchain not available
~/bug$ GOTOOLCHAIN=auto go build
go: downloading go1.22 (darwin/amd64)
go: download go1.22 for darwin/amd64: toolchain not available
~/bug$ GOTOOLCHAIN=auto go build ./...
go: downloading go1.22 (darwin/amd64)
go: download go1.22 for darwin/amd64: toolchain not available
@hyangah hyangah changed the title cmd/go: cmd/go: go toolchain version switch doesn't work when only language version is set in go.mod Feb 7, 2024
@fzipp
Copy link
Contributor

fzipp commented Feb 7, 2024

According to #62278 (comment) it has to be either

go 1.22.0

or

go 1.22
toolchain 1.22.0

@seankhliao
Copy link
Member

i think this is working as expected, 1.22 refers to the in development version, not a language version

@seankhliao
Copy link
Member

Duplicate of #62278

@seankhliao seankhliao marked this as a duplicate of #62278 Feb 7, 2024
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Feb 7, 2024
@hyangah
Copy link
Contributor Author

hyangah commented Feb 7, 2024

@fzipp go 1.22 is a valid syntax.
@seankhliao Thanks for the pointer to the issue. The spec allows a language version and when the toolchain is available to handle the language version, we need to do better (given all the confusion and noise in #62278).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants