-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: cannot recover from go env -w GOTOOLCHAIN=*
#59870
Comments
Probably |
Marking as release-blocker for 1.21 because |
Actually, I think that implies that you can't use |
@bcmills Won't the same sort of problem unfold any time a new variable gets added to go.env? For example, suppose Go 1.22 adds support for
Now everything will fail because 1.21 doesn't understand Even if |
But I don't see that that would help much for this particular case, because the same error will occur if you set |
Re "I still cannot set to an empty value", the command does set it to an empty value. It just prints a warning that your environment is still going to override the value if you keep your environment that way. |
Thinking out loud ... There are a few cases here. If you set GOTOOLCHAIN=garbage, then that will fail consistently, and you have to use If you set GOTOOLCHAIN=go1.19, that works fine for ordinary go commands, but you still have to use If you have Go 1.21 and you set go env -w GOTOOLCHAIN=go1.22, then the next go env -w VAR_INTRODUCED_IN_GO1.22=... needs to use Go 1.22; we can't just make go env -w be forced to use the local toolchain. Note that the go command already does ignore unrecognized settings in the file. It seems like encouraging GOTOOLCHAIN=local as the workaround is the right answer today. It's almost always a mistake to set go env -w GOTOOLCHAIN=go1.19 anyway (as opposed to setting a normal environment variable that way), so I'm not sure we have to worry too much about this case. On the other hand, suppose for the sake of argument that we special case |
Another option to consider is to allow only a couple of recognized values (e.g. The only reason I encountered this issue was because I was messing with it to prototype an experimental idea. I ended up creating a special environment variable for the purpose. |
@rsc any updates on this? This is currently marked as a release blocker and the freeze is coming soon. Thanks. |
Change https://go.dev/cl/496957 mentions this issue: |
If previously set an older version as GOTOOLCHAIN
or if entered a wrong version by mistake
Some ideas:
And
go env -w
cc @rsc @bcmills
EDIT: I found the following helps.
I still cannot set to an empty value
The text was updated successfully, but these errors were encountered: