I am trying to update a project from go 1.21 to 1.22, and in the process, my build got the error go: go.mod requires go >= 1.22 (running go 1.21.10; GOTOOLCHAIN=local)
.
So, I found some info on toolchain and ran go env -w GOTOOLCHAIN=go1.22+auto
in order to set the version of toolchain. When I ran go version
I got and have been getting the following error:
go: downloading go1.22 (darwin/amd64)
go: download go1.22 for darwin/amd64: toolchain not available
I was expecting
go 1.22
toolchain go1.22.0
Instead I got :
go: downloading go1.22 (darwin/amd64)
go: download go1.22 for darwin/amd64: toolchain not available
I found the following documentation on Go Toolchain (https://github.com/golang/go/issues/62278), and here (https://github.com/golang/go/issues/65568) and followed the suggestions to a T. However, 1.22 was reinstalled, and the same error occurred.
I have deleted every version of GO on this computer, the env file, all the GO folders, done everything I can to uninstall it, then even tried reinstalled a different version. Every time I uninstall/reinstall another version (say 1.21) and run "go version" it automatically reinstalls 1.22 and sends the same GOTOOLCHAIN error. I have also tried to set go work edit -toolchain=none
, but the results remain the same.
At this point, none of my go commands work, from go mod tidy
to go test
.
EDIT: I have deleted the env file, as well as unset the toolchain, however the error persists, as does the unwanted version of go.
GOTOOLCHAIN
unless you need that version to run globally for some reason without installing it yourself, not just to match a specific project. You set it to an invalid version, which is why it's returningtoolchain not available
, remove the invalidGOTOOLCHAIN
value. – WolseyGOTOOLCHAIN
is the problem and removing it is the solution: "I can only reproduce this if I set GOTOOLCHAIN to explicitly to "go1.22" (which is not a Go toolchain that exists):" and "A problem like that is fixable, as you've done, by unsetting the unwanted value ..." – Wolseyinvalid toolchain: go1.22 is a language version but not a toolchain version (go1.22.x)
(also discovered by reading the linked issue to find the followup) – Wolseydownload go1.22 for darwin/amd64: toolchain not available
it is because you still have the invalid value set somewhere in your environment. – Wolsey