-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: mod tidy reports toolchain not available with 'go 1.21' #62278
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
Comments
how did you end up with |
I can't remember exactly, but I think it was rather manual like: |
I am seeing this problem on linux/ppc64le.
|
@matthewhughes-uw, this is as expected: In general if you want to specify a development version in the go 1.21.0 or go 1.21
toolchain go1.21.0 |
@laboger, the problem you are seeing is similar. In particular, if you are working within |
As far as I can tell this is all working as designed. @matthewhughes-uw, are there specific documentation changes that would have helped you solve or avoid this problem? |
👍
I think the main issue was my assumption that, previously I could just specify a language version (per https://go.dev/doc/toolchain#version) i.e.
and within the linked page
so I guess it wasn't clear to me that a "language version" != a "Go release version" (though it was true for every language version before Go 1.21)
🤔 Maybe it's worth documenting something like "If you want to specify a 'language version' in |
Set golang version to `v1.21.0`, s. golang/go#62278 (comment)
To add to this: what really happened here that causes a bit of confusion is that the value of Before 1.21 release With 1.21 release you most likely want to put So the way I see it we went from Having now also |
According to [1] as of Go 1.21 we either need to specify the full toolchain version in the `go` directive or add a `toolchain` directive with the concrete toolchain version. Opt for the former and make sure it's kept up to date by renovate bot. [1] golang/go#62278 (comment) Signed-off-by: Tobias Klauser <tobias@cilium.io>
According to [1] as of Go 1.21 we either need to specify the full toolchain version in the `go` directive or add a `toolchain` directive with the concrete toolchain version. Opt for the former and make sure it's kept up to date by renovate bot. [1] golang/go#62278 (comment) Signed-off-by: Tobias Klauser <tobias@cilium.io>
…cussions/65431 Signed-off-by: David J. M. Karlsen <david.johan.macdonald.karlsen@dnb.no>
Unfortunately even if as a library author you attempt to write -go 1.23
+go 1.23.0
+
+toolchain go1.23.6 So really you still end up having to specify a minor (i.e., |
@dnwe Do any of your module's dependencies have a go directive of |
Yep all the x/ repos have bumped to go 1.23.0 now so pretty much everyone does 😅 (e.g., golang/crypto@89ff08d) My understanding was that 1.23 was ultimately meant to be a synonym of 1.23.0 though, so it seems like the go cli should treat them as comparable |
@dnwe I think I missed something in your previous comment. If your goal is for your requirement to be that "I'm happy for people using any go1.23.x or newer toolchain to import my library" then 1.23.0 is the correct requirement. About 1.23 vs 1.23.0: Because 1.23 doesn't allow pre-release versions, 1.23.0 is a higher minimum go version requirement than 1.23. So if you've taken a transitive dependency on a module version (like your example of golang.org/x/crypro@89ff08d) that requires a minimum Go version of 1.23.0 then your module's minimum Go version requirement is increased to 1.23.0. You should still be able to set your module's minimum Go version requirement to 1.24 (rather than 1.24.0) if none of your module's transitive dependencies require a higher version, such as 1.24.0. To require 1.23 you'd have to downgrade all your transitive requirements to versions before the requirement on go 1.23.0 was introduced. 1.23 and 1.23.0 are not meant to be synonyms. There is one case where we collapse the two: in the default case when |
@matloob I guess (as a library module author) I really just miss the behaviour that was present from Go 1.11 - Go 1.19, whereby I only ever had to touch the Now unless I code my modules to be entirely dependency-free, my choice of I would have much preferred a model whereby |
**Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> We currently use `go 1.21` in all go.mod files, this PR changes all go.mod files to include the minor version by using `go 1.21.0`. It seems that using the minor version is recommended by the Go project: golang/go#62278. One of the dependencies in collector-contrib also uses `go 1.21.0`, so this will need to be updated eventually anyways: https://github.com/cilium/ebpf/blob/main/go.mod#L3. **Link to tracking Issue:** <Issue number if applicable> **Testing:** <Describe what testing was performed and which tests were added.> **Documentation:** <Describe the documentation added.> --------- Co-authored-by: Antoine Toulme <antoine@toulme.name>
This comment has been minimized.
This comment has been minimized.
Since they started releasing .0 versions with 1.21.0, the go version need to be a full release version specifier and not a go language version. They relented and added support for defaulting to a .0 release if none is specified in later 1.23.x releases, but for users with local 1.21 or 1.22 toolchains the lack of a full release specifier breaks them. And going forwards this is more technically correct anyway. See golang/go#62278 (comment)
Since they started releasing .0 versions with 1.21.0, the go version need to be a full release version specifier and not a go language version. They relented and added support for defaulting to a .0 release if none is specified in later 1.23.x releases, but for users with local 1.21 or 1.22 toolchains the lack of a full release specifier breaks them. And going forwards this is more technically correct anyway. See golang/go#62278 (comment)
- **PR Description** Since they started releasing .0 versions with 1.21.0, the go version need to be a full release version specifier and not a go language version. They relented and added support for defaulting to a .0 release if none is specified in later 1.23.x releases, but for users with local 1.21 or 1.22 toolchains the lack of a full release specifier breaks them. And going forwards this is more technically correct anyway. See golang/go#62278 (comment)
When reading golang/go#62278 (comment) I noticed that this is only recommended for development versions which are not released yet. This is no longer valid, by default the recommendation is to not use the patch level. If you need to pin to a explicit version, toolchain should be used since 1.21 instead, like `toolchain go1.24.3`. Setting just `go 1.24` will avoid failures if developers do not install the latest patch level yet, but allow the build to pick the most recent patch level.
When reading golang/go#62278 (comment) I noticed that this is only recommended for development versions which are not released yet. This is no longer valid, by default the recommendation is to not use the patch level. If you need to pin to a explicit version, toolchain should be used since 1.21 instead, like `toolchain go1.24.3`. Setting just `go 1.24` will avoid failures if developers do not install the latest patch level yet, but allow the build to pick the most recent patch level.
This diagnostic was introduced by #15979. However in the meantime the Go team [has backtracked](golang/go#62278 (comment)) on their decision, which leads to confusing alerts for user (e.g. github/codeql-action#2868). Even using Go toolchains from 1.21 to 1.22 we weren't immediately able to reproduce the problem that this diagnostics was meant to guard against. Therefore it was deemed simpler to just remove it. _En passant_ the `Makefile` now accepts `rtjo` not being set.
Note: I think this is a question of: is "
go 1.21
" a valid go directive? since there was no1.21
release, only1.21.0
, perhaps notWhat version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, reproduced on Go 1.21.0
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Given a basic
go.mod
Then run:
What did you expect to see?
go mod tidy
runs successfully. I guess I expect it would pickgo1.21.0
as the toolchain if no toolchain is available as1.21
What did you see instead?
The error output above with a non-zero exit code
More details
The issue was seen when running
dependabot
on a repo with ago 1.21
directive ingo.mod
, theGOTOOLCHAIN
above was taken from their usage https://github.com/dependabot/dependabot-core/blob/08ac25ebd773cede0c00be9a98e5bb03b680870b/go_modules/Dockerfile#L34Running the above command with
GODEBUG=http2debug=1
I see it:go.dev/dl/mod/golang.org/toolchain/@v/v0.0.1-go1.21.linux-amd64.zip
which returnsLocation: https://go.dev/dl/mod/golang.org/toolchain/@v/v0.0.1-go1.21.linux-amd64.zip
location: https://dl.google.com/go/v0.0.1-go1.21.linux-amd64.zip
Updating the directive to:
go 1.21.0
will permit things to run fine.Update: closed per #62278 (comment)
The text was updated successfully, but these errors were encountered: