-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: GOTOOLCHAIN=version+auto doesn't use the named version in go install package@version #69051
Comments
GOTOOLCHAIN=<name>+auto
doesn't seem to work with go install
cc @rsc So it looks like what's happening here is that we start toolchain selection, determine the When that happens we try to do the required switch that's determined (https://cs.opensource.google/go/go/+/master:src/cmd/go/internal/toolchain/select.go;l=682;drc=c71b5ff76a1b1d79b53e268b83fb721e0af4614b) and to do that we load the do a query for the requested package@version and try to do a switch if we get a TooNewError. But the TooNewError is based on the requested module's version being newer than the local toolchain version-- it doesn't take into account the That by itself would be okay, because we run the toolchain switching logic again in the child and determine a toolchain version of 1.23, but then we see that we were invoked as a target toolchain, and that the version we switched to is the local version of the binary (https://cs.opensource.google/go/go/+/master:src/cmd/go/internal/toolchain/select.go;l=235;drc=c71b5ff76a1b1d79b53e268b83fb721e0af4614b) so we throw away the 1.23 version we determined in the second round of toolchain selection and continue execution of the go command at the local 1.22.6 version. I would need to consult with other team members on this but it sounds to me like we should either change the logic in goInstallVersion to take the |
Go version
go1.21.13 linux/amd64
Output of
go env
in your module/workspace:What did you do?
I believe this reproduces with more recent Go versions as well, but since the bug is about upgrading Go toolchain versions it's easier to demonstrate with an older version.
Here's what happens when I use the go command bundled with 1.21.13:
Here's what happens when I use the go command bundled with 1.23.0:
What did you see happen?
With
GOTOOLCHAIN=go1.23.0+auto
, Go 1.21.13 built the binary with Go 1.22.6.What did you expect to see?
I would expect both invocations to build staticcheck using Go 1.23.0.
honnef.co/go/tools/cmd/[email protected]
hasgo 1.22.1
in itsgo.mod
. So it makes sense that I've I'm using Go 1.21.13, if I ranGOTOOLCHAIN=auto go install honnef.co/go/tools/cmd/[email protected]
, it would use Go 1.22.6 since that's the latest patch release of the previous Go version and that's the minimum version of the three options documented at https://go.dev/doc/toolchain#switch.However, as documented at https://go.dev/doc/toolchain#intro, the
<name>+auto
form of theGOTOOLCHAIN
var essentially tells the Go tool to use the maximum of<name>
and whatever Go versionauto
would use:As far as I can tell,
go install
is entirely ignoring the<name>
part of<name>+auto
and just behaving the same as if I'd usedGOTOOLCHAIN=auto
.The text was updated successfully, but these errors were encountered: