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: download go1.22 for darwin/arm64: toolchain not available #65568

Closed
EwenQuim opened this issue Feb 7, 2024 · 15 comments
Closed

cmd/go: download go1.22 for darwin/arm64: toolchain not available #65568

EwenQuim opened this issue Feb 7, 2024 · 15 comments
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@EwenQuim
Copy link

EwenQuim commented Feb 7, 2024

Go version

go1.22

Output of go env in your module/workspace:

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

What did you do?

rm -rf /usr/local/go/
rm -rf ~/go

Then used the installer.

image

Then ran the command go version.

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

go env also returns this result.

image

What did you see happen?

go: download go1.22 for darwin/arm64: toolchain not available, not much more

What did you expect to see?

go1.22

@dmitshur
Copy link
Contributor

dmitshur commented Feb 7, 2024

Thanks for reporting. What's the output of which go and GOTOOLCHAIN=local go env?

(As a side note, when it's working as intended, it's not necessary to rm -rf /usr/local/go before running the macOS installer to upgrade. If there is a previous Go installation there, the installer will let you know and take care of removing it.)

@adamdecaf
Copy link
Contributor

I've installed Go with homebrew and am on an Intel mac.

go: downloading go1.22 (darwin/amd64)
go: download go1.22 for darwin/amd64: toolchain not available
$ which go
/usr/local/bin/go

$ GOTOOLCHAIN=local go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/Users/adam/Library/Caches/go-build'
GOENV='/Users/adam/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/adam/code/pkg/mod'
GONOPROXY='github.com/moov-io/*,github.com/moovfinancial/*'
GONOSUMDB='github.com/moov-io/*,github.com/moovfinancial/*'
GOOS='darwin'
GOPATH='/Users/adam/code/'
GOPRIVATE='github.com/moov-io/*,github.com/moovfinancial/*'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/Cellar/go/1.21.6/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/local/Cellar/go/1.21.6/libexec/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.21.6'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/adam/code/src/github.com/moov-io/irs/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/5c/9jlzxrmd1_7_fw3d05nb62dc0000gn/T/go-build2824011357=/tmp/go-build -gno-record-gcc-switches -fno-common'

@dmitshur
Copy link
Contributor

dmitshur commented Feb 7, 2024

@adamdecaf Since your Go toolchain was installed using a different tool, it's hard to know if it's the same problem or a different homebrew-specific problem. Let's wait to hear back from @EwenQuim or someone who's able to reproduce this the problem that affects the Go installer from go.dev/dl/.

@dmitshur dmitshur added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Feb 7, 2024
@fzipp
Copy link
Contributor

fzipp commented Feb 7, 2024

GOMOD='/Users/adam/code/src/github.com/moov-io/irs/go.mod'

Does this go.mod file say go 1.22 or go 1.22.0? Because according to #62278 (comment) go 1.22 without a more specific toolchain directive is not sufficient.

@EwenQuim
Copy link
Author

EwenQuim commented Feb 7, 2024

which go : /usr/local/go/bin/go

GOTOOLCHAIN=local go env
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/ewenq/Library/Caches/go-build'
GOENV='/Users/ewenq/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/ewenq/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/ewenq/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.0'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/5g/q9_gydg96zzd59zgh0hscvqh0000gn/T/go-build2955048168=/tmp/go-build -gno-record-gcc-switches -fno-common'

I don't see anything wrong here, but it might be only my local setup

@dmitshur dmitshur removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Feb 7, 2024
@seankhliao
Copy link
Member

is this in a module (if yes, what's the go directive in there)?
what's the GOTOOLCHAIN env set to?
what's in /Users/ewenq/Library/Application Support/go/env?

@seankhliao seankhliao added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Feb 7, 2024
@dmitshur
Copy link
Contributor

dmitshur commented Feb 7, 2024

@EwenQuim Thanks.

Can you post more complete steps for how to reproduce it, in an empty directory?

For example, does it reproduce if you do the following sequence?

cd $(mktemp -d)
go version

Is the GOTOOLCHAIN variable set in your environment?

I can only reproduce this if I set GOTOOLCHAIN to explicitly to "go1.22" (which is not a Go toolchain that exists):

$ cd $(mktemp -d)
$ GOTOOLCHAIN=go1.22 go version
go: downloading go1.22 (darwin/arm64)
^C

Otherwise it doesn't reproduce:

$ cd $(mktemp -d)
$ echo $GOTOOLCHAIN

$ go version
go version go1.22.0 darwin/arm64

@dmitshur dmitshur changed the title go: download go1.22 for darwin/arm64: toolchain not available cmd/go: download go1.22 for darwin/arm64: toolchain not available Feb 7, 2024
@EwenQuim
Copy link
Author

EwenQuim commented Feb 7, 2024

@seankhliao

is this in a module (if yes, what's the go directive in there)?

No

what's the GOTOOLCHAIN env set to?

Nothing
image

what's in /Users/ewenq/Library/Application Support/go/env?

image

@EwenQuim
Copy link
Author

EwenQuim commented Feb 7, 2024

OK the problem is solved after I deleted the /Users/ewenq/Library/Application Support/go/env file, thank you very much !

Sorry for taking some of your time, I will explain the cause of the bug below if you're interested, but no need to search more.

@EwenQuim EwenQuim closed this as completed Feb 7, 2024
@dmitshur
Copy link
Contributor

dmitshur commented Feb 7, 2024

Thanks. It's good to understand that the GOTOOLCHAIN=go1.22 line in the go/env file was causing this, and that it's not a problem with the Go installer.

A problem like that is fixable, as you've done, by unsetting the unwanted value with GOTOOLCHAIN=local go env -u GOTOOLCHAIN or by manually editing (or deleting) that file.

@EwenQuim
Copy link
Author

EwenQuim commented Feb 7, 2024

The invalid version of GOTOOLCHAIN that was causing me the same issue again and again even after deleting and reinstalling the /usr/local/go directory.

Good learning for me: the /usr/local/go directory isn't the only place Go config lives on my computer.

Maybe that updating the go.dev page with more information can be a good idea to prevent future issues like this one ?

image

juev added a commit to kevincobain2000/gobrew that referenced this issue Feb 10, 2024
After updating golang to 1.22 we have error:
```
go: download go1.22 for darwin/arm64: toolchain not available
```

golang/go#65568

Just set full version for golang to fix this issue
kevincobain2000 pushed a commit to kevincobain2000/gobrew that referenced this issue Feb 11, 2024
* fix: toolchain not available

After updating golang to 1.22 we have error:
```
go: download go1.22 for darwin/arm64: toolchain not available
```

golang/go#65568

Just set full version for golang to fix this issue

* fix: add build tag to windows cmd

goland added this automatically :)

* feat: add golangci-lint to build

Using golangci-link makes it easier to check the code and avoid a lot of problems

* fix: linters warnings

* fix: a more specific definition of exclusion for gocritic
@Forfold
Copy link

Forfold commented Feb 14, 2024

SOLVED

I'm also running into this with Homebrew, and don't have a go/env directory. I have a /go directory in my Library/Application Support folder, but no /env within it

which go returns /opt/homebrew/bin/go

I recently upgraded my work laptop so this is a relatively new environment, and I have never run into this before, though I have always been using Homebrew.

Edit: My laptop's specs are a 16" 2023 Apple M2 Max. I tried brew uninstall go followed by brew install go to no avail- I get the same error after checking the version within my repo. If I do go version within a new terminal (vanilla bash), I do get go version go1.21.7 darwin/arm64

Output of go env -u GOTOOLCHAIN:

go: reading go env config: open /Users/Z0027PF/Library/Application Support/go/env: no such file or directory

Edit 2: Since go version worked in a new terminal but not in my repo's dir terminal within VScode, I figured it was something project related at this point. After finding this comment I updated my go.mod file to include the .0 and everything built just fine.

@kfelter
Copy link

kfelter commented Feb 20, 2024

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

Then Quit and Reopened VS Code

@ldemailly
Copy link

Thanks for that last comment

I think it's very counter intuitive for go version to not output the actual binary version but instead start doing something else that depends on files in the current directory. I can't think of any other unix binary doing that (there is also no debug or verbose I can't see that explains that behavior, like "using go version from go.mod" output somewhere, after printing the actual current binary version

seems you have to do crazy stuff like

DIR=$(mktemp -d); cd $DIR; go version
go version go1.21.8 darwin/arm64

to get the actual go version instead of

$ go version
go: downloading go1.22 (darwin/arm64)
go: download go1.22 for darwin/arm64: toolchain not available

also probably should say "go.mod has go 1.22 which isn't semantic versioning, please correct to 1.22.0"
or fix the behavior so 1.22 means... like it used to... "latest release of 1.22" instead of failing?

@dmitshur
Copy link
Contributor

you have to do [...] DIR=$(mktemp -d); cd $DIR; go version

If you'd like to determine the bundled Go toolchain's version, it's possible to do it with GOTOOLCHAIN=local go version. This is documented in the last paragraph of https://go.dev/doc/toolchain#select. The rest of that document provides useful context for the current behavior.

also probably should say "go.mod has go 1.22 which isn't semantic versioning, please correct to 1.22.0"
or fix the behavior so 1.22 means... like it used to... "latest release of 1.22" instead of failing?

@ldemailly You're right that this can be improved. This is now tracked in issue #66175. Please feel free to follow it for updates.

Since this issue is closed and there's another open one to track this problem, I'll lock this to avoid further replies pinging many people. If someone would like to report a different problem, please file a new issue at go.dev/issue/new. Thanks.

@golang golang locked as resolved and limited conversation to collaborators Mar 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

8 participants