bazel-contrib / rules_go

Go rules for Bazel
Apache License 2.0
1.39k stars 664 forks source link

Buildifier fails to run with rules_proto v7.0.0 #4169

Closed johanbrandhorst closed 1 week ago

johanbrandhorst commented 2 weeks ago

What version of rules_go are you using?

v0.50.1

What version of gazelle are you using?

v0.39.1

What version of Bazel are you using?

v7.4.0

Does this issue reproduce with the latest releases of all the above?

Yes

What operating system and processor architecture are you using?

Linux/amd64

Any other potentially useful information about your toolchain?

I'm using rules_proto v7.0.1.

What did you do?

I upgraded to rules_proto v7.0.1 and ran buildifier.

What did you expect to see?

A successful build

What did you see instead?

A build failure:

$ bazel run //:buildifier && git diff --exit-code
Computing main repo mapping: 
Loading: 
Loading: 0 packages loaded
Analyzing: target //:buildifier (0 packages loaded, 0 targets configured)
Analyzing: target //:buildifier (0 packages loaded, 0 targets configured)

ERROR: Traceback (most recent call last):
    File "/github/home/.cache/bazel/_bazel_root/13dc60d22ee138725abf21b91435297b/external/io_bazel_rules_go/proto/private/toolchain.bzl", line 20, column 6, in <toplevel>
        "ProtoLangToolchainInfo",
Error: file '@rules_proto//proto:proto_common.bzl' does not contain symbol 'ProtoLangToolchainInfo'
ERROR: error loading package '@@io_bazel_rules_go//proto/private': initialization of module 'proto/private/toolchain.bzl' failed
ERROR: /github/home/.cache/bazel/_bazel_root/13dc60d22ee138725abf21b91435297b/external/io_bazel_rules_go/proto/BUILD.bazel:24:18: every rule of type _go_proto_compiler implicitly depends upon the target '@@io_bazel_rules_go//proto/private:legacy_proto_toolchain', but this target could not be found because of: error loading package '@@io_bazel_rules_go//proto/private': initialization of module 'proto/private/toolchain.bzl' failed
ERROR: Analysis of target '//:buildifier' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.337s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
FAILED: 
ERROR: Build failed. Not running target

Full build log

It seems like rules_go depends on ProtoLangToolchainInfo, which it appears is no longer exported from rules_proto. The change is in https://github.com/bazelbuild/rules_proto/commit/7083178d2b8a07036b4319df3e9952aff6c6df15 which made it into v7.0.0 of rules_proto. It's unclear to me how to fix this, as a user of both libraries (the grpc-gateway project).

fmeum commented 1 week ago

Please update to rules_proto v7.0.2, which added back the symbol: https://github.com/bazelbuild/rules_proto/releases/tag/7.0.2