The same is true with or without clearing the Go cache.
Upgrading to versions below 1.22.0 e.g. go_register_toolchains(version = "1.21.13") does not fail to build, but due to a transitive requirement still updates go.mod to incorrectly claim go 1.22.7
brian:~/repos/agent$ bazel run @io_bazel_rules_go//go -- mod tidy && bazel run //:gazelle-update-repos && bazel run //:gazelle --verbose_failures
INFO: Analyzed target @@io_bazel_rules_go//go:go (9 packages loaded, 9615 targets configured).
INFO: Found 1 target...
Target @@io_bazel_rules_go//go/tools/go_bin_runner:go_bin_runner up-to-date:
bazel-bin/external/io_bazel_rules_go/go/tools/go_bin_runner/bin/go
INFO: Elapsed time: 36.223s, Critical Path: 16.54s
INFO: 11 processes: 6 internal, 5 linux-sandbox.
INFO: Build completed successfully, 11 total actions
INFO: Running command line: bazel-bin/external/io_bazel_rules_go/go/tools/go_bin_runner/bin/go mod tidy
go: finding module for package github.com/apenella/go-ansible/v2/pkg/playbook
...
go: finding module for package github.com/apenella/go-ansible/v2/pkg/execute
go: toolchain upgrade needed to resolve github.com/apenella/go-ansible/v2/pkg/execute
go: github.com/apenella/go-ansible/v2@v2.0.1 requires go >= 1.22; switching to go1.22.7
go: finding module for package github.com/apenella/go-ansible/v2/pkg/playbook
go: finding module for package google.golang.org/grpc
...
go: found github.com/apenella/go-ansible/v2/pkg/playbook in github.com/apenella/go-ansible/v2 v2.0.1
INFO: Analyzed target //:gazelle-update-repos (94 packages loaded, 11102 targets configured).
INFO: Found 1 target...
Target //:gazelle-update-repos up-to-date:
bazel-bin/gazelle-update-repos-runner.bash
bazel-bin/gazelle-update-repos
INFO: Elapsed time: 10.162s, Critical Path: 9.21s
INFO: 41 processes: 1 internal, 40 linux-sandbox.
INFO: Build completed successfully, 41 total actions
INFO: Running command line: bazel-bin/gazelle-update-repos
INFO: Analyzed target //:gazelle (34 packages loaded, 449 targets configured).
INFO: Found 1 target...
Target //:gazelle up-to-date:
bazel-bin/gazelle-runner.bash
bazel-bin/gazelle
INFO: Elapsed time: 1.899s, Critical Path: 1.67s
INFO: 37 processes: 1 internal, 36 linux-sandbox.
INFO: Build completed successfully, 37 total actions
INFO: Running command line: bazel-bin/gazelle
What version of rules_go are you using?
v0.44.2
What version of gazelle are you using?
v0.35.0
What version of Bazel are you using?
7.1.0
Does this issue reproduce with the latest releases of all the above?
Yes
What operating system and processor architecture are you using?
Ubuntu amd64
Any other potentially useful information about your toolchain?
Using WORKSPACE-based Gazelle deps due to incompatibilities with other dependencies not yet on bzlmod (namely https://github.com/stackb/rules_proto)
What did you do?
Updated
go_register_toolchains(version = "1.20.7")
togo_register_toolchains(version = "1.22.0")
, cleared out go.mod and ranbazel run @io_bazel_rules_go//go -- mod tidy && bazel run //:gazelle-update-repos && bazel run //:gazelle --verbose_failures
What did you expect to see?
Linking and build succeeds
What did you see instead?
The same is true with or without clearing the Go cache.
Upgrading to versions below 1.22.0 e.g.
go_register_toolchains(version = "1.21.13")
does not fail to build, but due to a transitive requirement still updates go.mod to incorrectly claimgo 1.22.7