rules_go
rules_go copied to clipboard
Unable to download golang 1.22 toolchain
What version of rules_go are you using?
v0.45.1
What version of gazelle are you using?
0.26.0
What version of Bazel are you using?
5.4.0
Does this issue reproduce with the latest releases of all the above?
Unsure
What operating system and processor architecture are you using?
x86_64 Linux
Any other potentially useful information about your toolchain?
What did you do?
Download golang toolchain with
go_download_sdk(
name = "go_sdk",
goarch = "amd64",
goos = "linux",
)
Please note no version is specified and should use latest version.
What did you expect to see?
Download success
What did you see instead?
ERROR: /usr/local/google/home/xyz/workspace/cluster-operators/WORKSPACE:36:16: fetching go_download_sdk_rule rule //external:go_sdk: Traceback (most recent call last):
File "/usr/local/google/home/xyz/.cache/bazel/_bazel_xyz/390359d02f81fc440c9ec00323252b81/external/io_bazel_rules_go/go/private/sdk.bzl", line 108, column 17, in _go_download_sdk_impl
fail("did not find version {} in https://go.dev/dl/?mode=json".format(version))
Error in fail: did not find version 1.22 in https://go.dev/dl/?mode=json
Looks like the same issue as #3644
I think you should write it as 1.22.0
.
I think you should write it as
1.22.0
.
According to the doc, it should automatically use latest Golang SDK if version
is not specified.
Are you certain that you aren't picking up an old version of rules_go from a dependency? Could you perhaps share a reproducer?
Are you certain that you aren't picking up an old version of rules_go from a dependency? Could you perhaps share a reproducer?
Yes, the WORKSPACE file contains the following:
3 http_archive(
4 name = "io_bazel_rules_go",
5 sha256 = "6734a719993b1ba4ebe9806e853864395a8d3968ad27f9dd759c196b3eb3abe8",
6 urls = [
7 "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.45.1/rules_go-v0.45.1.zip",
8 ],
9 )
It's likely an earlier entry in your WORKSPACE has an indirect/transitive require of an older version of io_bazel_rules_go. Can you try to move your io_bazel_rules_go
block to the top of WORKSPACE and see if that helps?
It's likely an earlier entry in your WORKSPACE has an indirect/transitive require of an older version of io_bazel_rules_go. Can you try to move your
io_bazel_rules_go
block to the top of WORKSPACE and see if that helps?
It is the first rule in our WORKSPACE file.
Now, the issue has been resolved itself because Go just released 1.22.1
. It seems this rule basically cannot latest version when the latest is the initial release of a Go minor version.
This has happened before (see #3644 ). The versioning scheme has changed, so you have to use 1.22.0
, not 1.22
, as @hawkingrei suggested above.
According to the doc, it should automatically use latest Golang SDK if version is not specified.
In my experience @baizhenyu its more like a "recent version" than the latest.
I had an issue that took me DAYS to troubleshoot, I was getting a weird error when trying to use math/rand/v2
which is only available in 1.22:
gazelle: finding module path for import math/rand/v2: go: malformed module path "math/rand/v2": missing dot in first path element
After a lot of head bashing, I found bazel
was downloading a "recent" version, not "latest", so I had to edit MODULE.bazel
to add:
go_sdk.download(version = "1.22.0")
(Before I did not have a go_sdk.download
entry as I was relying on the default behaviour which I THOUGHT meant the latest).
We want the default SDK version to be deterministic, but that also means that bumping it requires a new Go release. If you really always want to use the latest version, try go_sdk.download()
.
Please read the latest doc of go_download_sdk
:
The version of Go to download, for example 1.12.5. If unspecified, go_download_sdk will list available versions of Go from golang.org, then pick the highest version.
It is supposed to download the latest version of Go and it is always the case for us. There is just something broken in rules_go
when Go changed its initial minor version schema and no one ever fixed it.