bazelbuild / rules_go

Go rules for Bazel
Apache License 2.0
1.35k stars 635 forks source link

How do you use protoc with 0.48.0? #3948

Closed johanbrandhorst closed 1 month ago

johanbrandhorst commented 1 month ago

My repository attempted to auto-upgrade to 0.48.0 and apparently you now need to "supply protoc as a toolchain"? What does this mean? I've tried various permutations for upgrading my WORKSPACE but can't get it to work. The error I'm seeing is:

ERROR: Skipping '//:gazelle': error loading package '': at /github/home/.cache/bazel/_bazel_root/13dc60d22ee138725abf21b91435297b/external/io_bazel_rules_go/proto/compiler.bzl:20:5: cannot load '@@rules_proto//proto:proto_common.bzl': no such file
ERROR: error loading package '': at /github/home/.cache/bazel/_bazel_root/13dc60d22ee138725abf21b91435297b/external/io_bazel_rules_go/proto/compiler.bzl:20:5: cannot load '@@rules_proto//proto:proto_common.bzl': no such file

Log here: https://github.com/grpc-ecosystem/grpc-gateway/actions/runs/9203675557/job/25315659356?pr=4356.

The PR changes are here: https://github.com/grpc-ecosystem/grpc-gateway/pull/4356. Any advice would be appreciated.

johanbrandhorst commented 1 month ago

Perhaps related: https://github.com/bazelbuild/rules_proto/issues/212? If there's some magic change I need to upgrade both of these together, that would also be fine.

fmeum commented 1 month ago

I just added rules_proto 6.0.0 or later as a new requirement to the release notes. Could you test whether that fixes the problem for you?

As long as you don't flip --incompatible_enable_proto_toolchain_resolution, you don't need to register any proto toolchains yourself.

I would highly recommend switching to MODULE.bazel with its proper version resolution for transitive dependencies.

johanbrandhorst commented 1 month ago

Thanks for the quick reply, updating rules_go and rules_proto simultaneously seems to work!

johanbrandhorst commented 1 month ago

Seeing a different error in rules_proto now actually but not sure it has anything to do with rules_go, just posting it here in case anyone else sees it too: https://github.com/bazelbuild/rules_proto/issues/212.