Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`toolchain not available` error prevents me from using any go commands

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.


1 Answers

Fixed it by editing the go.mod file.

changed go 1.22 to go 1.22.0

like image 73
mercybabe Avatar answered Sep 13 '25 02:09

mercybabe