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

1

7

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.

Giglio answered 22/5 at 19:46 Comment(5)
I would not set 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 returning toolchain not available, remove the invalid GOTOOLCHAIN value.Wolsey
In fact you didn't follow the linked issue "to a T", because it explains that the bad GOTOOLCHAIN 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 ..."Wolsey
FYI, the next release will report invalid 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)Wolsey
But how to resolve the error? I did unset the unwanted value like in the article, and I deleted that file- however the error persists, and the unwanted version of go also persists.Giglio
If you are getting download go1.22 for darwin/amd64: toolchain not available it is because you still have the invalid value set somewhere in your environment.Wolsey
G
11

Fixed it by editing the go.mod file go 1.22 go 1.22.0

Guileless answered 19/6 at 16:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.