bazelbuild / rules_go

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

Dependency cycle with google.golang.org/protobuf 1.33.0 #3894

Closed satreix closed 3 months ago

satreix commented 3 months ago

What version of rules_go are you using?

0.46.0 from the bcr

What version of gazelle are you using?

0.35.0 from the bcr

What version of Bazel are you using?

7.0.2

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

Yes.

What operating system and processor architecture are you using?

macOS x86-64

Any other potentially useful information about your toolchain?

NA

What did you do?

Upgrade google.golang.org/protobuf from 1.32.0 to 1.33.0

What did you expect to see?

Business as usual, passing build.

What did you see instead?

https://github.com/satreix/everest/pull/786

ERROR: /home/runner/.cache/bazel/_bazel_runner/b10ccf95f70cafd45527ff3170f0ab76/external/gazelle~0.35.0~go_deps~org_golang_google_protobuf/cmd/protoc-gen-go/BUILD.bazel:15:10: in go_binary rule @@gazelle~0.35.0~go_deps~org_golang_google_protobuf//cmd/protoc-gen-go:protoc-gen-go: cycle in dependency graph:
    //src/go/bookstore/cmd/client:client (b8f98ef38b69a906f20306349d603e9b1a129602b18bb3550d1756c4f5fa45c2)
    //src/go/bookstore/cmd/client:client (90f79465fd0e8d7571f9b07e0d4d0e25008ab72ed6d8b90b2ecdd817642dadb8)
    //src/go/bookstore/cmd/client:client_lib (90f79465fd0e8d7571f9b07e0d4d0e25008ab72ed6d8b90b2ecdd817642dadb8)
    @@gazelle~0.35.0~go_deps~org_golang_google_grpc//credentials/insecure:insecure (90f79465fd0e8d7571f9b07e0d4d0e25008ab72ed6d8b90b2ecdd817642dadb8)
    @@gazelle~0.35.0~go_deps~org_golang_google_grpc//credentials:credentials (90f79465fd0e8d7571f9b07e0d4d0e25008ab72ed6d8b90b2ecdd817642dadb8)
    @@gazelle~0.35.0~go_deps~com_github_golang_protobuf//proto:go_default_library (90f79465fd0e8d7571f9b07e0d4d0e25008ab72ed6d8b90b2ecdd817642dadb8)
    @@gazelle~0.35.0~go_deps~com_github_golang_protobuf//proto:proto (90f79465fd0e8d7571f9b07e0d4d0e25008ab72ed6d8b90b2ecdd817642dadb8)
    @@gazelle~0.35.0~go_deps~org_golang_google_protobuf//reflect/protodesc:protodesc (90f79465fd0e8d7571f9b07e0d4d0e25008ab72ed6d8b90b2ecdd817642dadb8)
    @@gazelle~0.35.0~go_deps~org_golang_google_protobuf//types/gofeaturespb:gofeaturespb (90f79465fd0e8d7571f9b07e0d4d0e25008ab72ed6d8b90b2ecdd817642dadb8)
    @@gazelle~0.35.0~go_deps~org_golang_google_protobuf//types/gofeaturespb:gofeaturespb_go_proto (90f79465fd0e8d7571f9b07e0d4d0e25008ab72ed6d8b90b2ecdd817642dadb8)
    @@rules_go~0.46.0//proto:go_proto (90f79465fd0e8d7571f9b07e0d4d0e25008ab72ed6d8b90b2ecdd817642dadb8)
    @@rules_go~0.46.0//proto:go_proto_reset_plugin_ (41097fba4ae32680fd388afbe1d13d7591001e368ce41bfc5d4429064890550f)
.-> @@gazelle~0.35.0~go_deps~org_golang_google_protobuf//cmd/protoc-gen-go:protoc-gen-go (33328f2e42d54da1b0779506372f2368ed44f8039e8de7744730a4981ca06d7e)
|   @@gazelle~0.35.0~go_deps~org_golang_google_protobuf//cmd/protoc-gen-go:protoc-gen-go_lib (33328f2e42d54da1b0779506372f2368ed44f8039e8de7744730a4981ca06d7e)
|   @@gazelle~0.35.0~go_deps~org_golang_google_protobuf//compiler/protogen:protogen (33328f2e42d54da1b0779506372f2368ed44f8039e8de7744730a4981ca06d7e)
|   @@gazelle~0.35.0~go_deps~org_golang_google_protobuf//reflect/protodesc:protodesc (33328f2e42d54da1b0779506372f2368ed44f8039e8de7744730a4981ca06d7e)
|   @@gazelle~0.35.0~go_deps~org_golang_google_protobuf//types/gofeaturespb:gofeaturespb (33328f2e42d54da1b0779506372f2368ed44f8039e8de7744730a4981ca06d7e)
|   @@gazelle~0.35.0~go_deps~org_golang_google_protobuf//types/gofeaturespb:gofeaturespb_go_proto (33328f2e42d54da1b0779506372f2368ed44f8039e8de7744730a4981ca06d7e)
|   @@rules_go~0.46.0//proto:go_proto (33328f2e42d54da1b0779506372f2368ed44f8039e8de7744730a4981ca06d7e)
|   @@rules_go~0.46.0//proto:go_proto_reset_plugin_ (33328f2e42d54da1b0779506372f2368ed44f8039e8de7744730a4981ca06d7e)
`-- @@gazelle~0.35.0~go_deps~org_golang_google_protobuf//cmd/protoc-gen-go:protoc-gen-go (33328f2e42d54da1b0779506372f2368ed44f8039e8de7744730a4981ca06d7e)
ERROR: Analysis of target '//src/go/bookstore/cmd/client:client' failed; build aborted
INFO: Elapsed time: 188.944s, Critical Path: 2.76s
INFO: 1901 processes: 1211 remote cache hit, 683 internal, 7 linux-sandbox.
ERROR: Build did NOT complete successfully
fmeum commented 3 months ago

This can be fixed with a Gazelle directive: https://github.com/bazelbuild/bazel-gazelle/commit/b3cddc07edbede6dd7a5c311aac7ac06660aecf0

If you use Bzlmod, this will also be active by default with the next Gazelle release.

Please reopen if the directive doesn't work for you.

satreix commented 3 months ago

Makes sense. I will use gazelle_override until the next release.

AFMiziara commented 3 months ago

@fmeum is it possible to disable only for "google.golang.org/protobuf" using gazelle directive when not using bzlmod?

fmeum commented 3 months ago

@AFMiziara Yes: https://github.com/bazelbuild/bazel-gazelle/blob/master/repository.md#go_repository-build_directives