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: reject to download toolchain when gotoolchain < go directive #72003

Open
xieyuschen opened this issue Feb 27, 2025 · 4 comments
Open
Labels
FixPending Issues that have a fix which has not yet been reviewed or submitted. GoCommand cmd/go ToolProposal Issues describing a requested change to a Go tool or command-line program.

Comments

@xieyuschen
Copy link
Contributor

xieyuschen commented Feb 27, 2025

What version of Go are you using (go version)?

$ go version
go version go1.24.0 darwin/arm64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
AR='ar'
CC='clang'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='clang++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/yuchen.xie/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/yuchen.xie/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/28/7sypdf0519xfl4ylhq_90s0m0000gp/T/go-build2459204566=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/Users/yuchen.xie/go/pkg/mod'
GONOPROXY='git.garena.com'
GONOSUMDB='git.garena.com'
GOOS='darwin'
GOPATH='/Users/yuchen.xie/go'
GOPRIVATE='git.garena.com'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='on'
GOTELEMETRYDIR='/Users/yuchen.xie/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.24.0'
GOWORK=''
PKG_CONFIG='pkg-config'
uname -v: Darwin Kernel Version 23.4.0: Fri Mar 15 00:10:42 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6000
ProductName:		macOS
ProductVersion:		14.4.1
BuildVersion:		23E224
lldb --version: lldb-1500.0.404.7
Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)

What did you do?

  • Case1:
mkdir verify && cd verify
go mod init m
go mod edit -go=1.26 -toolchain=go1.23.0
go version
  • Case2:
mkdir verify && cd verify
go mod init m
go mod edit -go=1.24 -toolchain=go1.23.0
<my-local-path>/bin/sdk/go1.21.10/bin/go version

What did you expect to see?

Both case 1 and case 2 should be rejected, because go.mod reference said.

The suggested Go toolchain’s version cannot be less than the required Go version declared in the go directive.

Hence, before we actually downloading toolchain, we should check the version inside go.mod and report an error.
For example, go: suggested go toolchain go1.23.0 cannot be less than required go version 1.24

Besides, the case2 looks weird in real usage.

What did you see instead?

  • case1:
go: downloading go1.26.0 (darwin/arm64)
go: download go1.26.0 for darwin/arm64: toolchain not available
  • case 2:
go: downloading go1.24 (darwin/amd64)
go: download go1.24 for darwin/amd64: toolchain not available
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/653237 mentions this issue: cmd/go: validate go and toolchain versions before downloading

@gabyhelp gabyhelp added the ToolProposal Issues describing a requested change to a Go tool or command-line program. label Feb 27, 2025
@matloob matloob added the GoCommand cmd/go label Feb 27, 2025
@dmitshur dmitshur added the FixPending Issues that have a fix which has not yet been reviewed or submitted. label Feb 27, 2025
@matloob
Copy link
Contributor

matloob commented Mar 31, 2025

I'm not sure that this is necessarily incorrect behavior. The toolchain sets a minimum required version for the toolchain- it doesn't pin the toolchain at that version.

@xieyuschen
Copy link
Contributor Author

I'm not sure that this is necessarily incorrect behavior. The toolchain sets a minimum required version for the toolchain- it doesn't pin the toolchain at that version.

HI @matloob , thanks for reply. I don't know whether it's wrong or not as well, but probably the error message 'toolchain not available' could be improved, as my CL does. The CL prints the error before it really starts to download(and fail).

In cases I mentioned above, go complains to me ''toolchain not available', and as a user I don't know what happened and how to fix it until I try to revise the toolchain to make it higher than go line.

It's quite confusing in case 2 as there is a go1.24 but why toolchain of go1.24 for darwin/amd64 is unavailable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FixPending Issues that have a fix which has not yet been reviewed or submitted. GoCommand cmd/go ToolProposal Issues describing a requested change to a Go tool or command-line program.
Projects
None yet
Development

No branches or pull requests

5 participants