-
Notifications
You must be signed in to change notification settings - Fork 27
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
Go does not download toolchains when the cachi2 Go version is newer than the specified toolchain #501
Comments
Hmm, I wonder if we can ultimately provide a generic fix that would cover all user scenarios as consumers must not blindly assume we'll deal with everything, they need to cooperate by selecting an image that on its own can attain what they want, i.e. building the project. Consider the following scenarios and go.mod contents:
Because cachi2 has a newer toolchain, 1.21.5 won't be downloaded, we set
This is a user problem, because they strictly mandate go 1.21.5 , yet the base image they build with doesn't even comply with cachi2 out of the picture (note that cachi2 in this case has a good argument of using whatever the latest Go version is). This would fail either way (unless we employ one of the suggestions below), so I wonder whether it's okay for us to do nothing and let it fail with a more confusing error about not being able to download the toolchain because of Despite the above, there are options for us to go more than one step further and basically walk the consumers by the hand through the whole process taking care of their own problems: change our base image and be in full control of the Go version in itThis is already being discussed here, so a TL;DR is that we'd install the first minor release of all supported Go SDKs (e.g. go1.21.0) and always set download any toolchain explicitlyWe do have a code foundation to download toolchains already, but we decided to only ever fall back to using that code path with local environments rather than container based environments. The arguments against using this solution in container-based envs are:
|
In retrospect, ^this won't work with submodules or workspaces if each submodule requires a different version of Go by the means of the So I think as discussed via private channels the only reasonable fix for this is to At the same time, we'd stop forcing any @taylormadore any objections to the paragraph above^? |
Nope, looks good to me 👍. Thank you for all of your efforts on this feature ❤️ |
Resolved with e0732c7 |
Cachi2 does not provide a toolchain in GOMODCACHE when the installed version of Go in the cachi2 image is the same or newer than specified by the
toolchain
directive ingo.mod
. This behavior of Go is noted in the documentation for Go toolchains [1]:This may cause an issue when performing a hermetic build from the cachi2-output where the
GOTOOLCHAIN
environment variable is set toauto
. If the builder image does not have a version of Go matching or exceeding that specified by thetoolchain
directive, the build may fail when trying to fetch the toolchain.References
[1] https://go.dev/doc/toolchain
[2] #419 (Go 1.21 design doc)
The text was updated successfully, but these errors were encountered: