rules-proto-grpc / rules_proto_grpc

Bazel rules for building Protobuf and gRPC code and libraries from proto_library targets
https://rules-proto-grpc.com
Apache License 2.0
249 stars 156 forks source link

gateway_grpc_library is broken with latest version of rules_go and gazelle #275

Closed alexbozhenko closed 4 weeks ago

alexbozhenko commented 1 year ago

Issue Description

The rules_go 0.41.0 and gazelle 0.32.0 added the breaking go_googleapis change.

This repo uses go_googleapis in multiple places. E.g.: gateway_grpc_library

I am trying to update my repo to use go 1.21. That requires the latest version or gazelle and rules_go. When I am trying to use gateway_grpc_library in a repo that has the latest version, I get the following error, even though go_googleapis is not defined/used anywhere in my repo.

I know this is not a proper bug report, and I will need to provide a reproducer, but I wanted to check and see if updating the version of rules_go and gazelle can break gateway_grpc_library, or is it something else in my repo setup that is more likely to be broken? UPD: I tried to update versions here: https://github.com/rules-proto-grpc/rules_proto_grpc/pull/277

I did try to include https://github.com/googleapis/googleapis repo and gazelle:resolve stanzas as per the advice in the release notes for rules_go, but still that did not work.

So I am wondering if the fix that fix is also needed to repositories.bzl in this repo, if it were to be used with the latest rules_go?

Log Output

plain text ERROR: /var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/5a6fc9ff7fa4373be5f3f379b34ac692/external/rules_proto_grpc/grpc-gateway/example/api/BUILD.bazel:4:14: no such package '@go_googleapis//google/api': The repository '@go_googleapis' could not be resolved: Repository '@go_googleapis' is not defined

rules_proto_grpc Version

4.4.0

Bazel Version

6.3.2

OS

Ubuntu 22.04

Link to Demo Repo

No response

WORKSPACE Content

No response

BUILD Content

No response

Proto Content

No response

Any Other Content

No response

alexbozhenko commented 11 months ago

Thanks @sluongng for the suggestion, I was able to patch it like this:

http_archive(
    name = "rules_proto_grpc",
    sha256 = "f87d885ebfd6a1bdf02b4c4ba5bf6fb333f90d54561e4d520a8413c8d1fb7beb",
    strip_prefix = "rules_proto_grpc-4.5.0",
    patch_args = ["-p1"],
    patches = ["//buildpatches:gateway_grpc_library.bzl.patch",],
    urls = [
        "https://github.com/rules-proto-grpc/rules_proto_grpc/archive/refs/tags/4.5.0.tar.gz",
    ],
)
$ cat buildpatches/gateway_grpc_library.bzl.patch
diff --git a/grpc-gateway/gateway_grpc_library.bzl b/grpc-gateway/gateway_grpc_library.bzl
index 91cedbfe..0b3fbae1 100644
--- a/grpc-gateway/gateway_grpc_library.bzl
+++ b/grpc-gateway/gateway_grpc_library.bzl
@@ -38,5 +38,5 @@ GATEWAY_DEPS = [
     "@org_golang_google_grpc//metadata:go_default_library",
     "@com_github_grpc_ecosystem_grpc_gateway_v2//runtime:go_default_library",
     "@com_github_grpc_ecosystem_grpc_gateway_v2//utilities:go_default_library",
-    "@go_googleapis//google/api:annotations_go_proto",
+    "@org_golang_google_genproto_googleapis_api//annotations",
 ]
alexbozhenko commented 11 months ago

@aaliddell looks like you have been active in the repo recently. Can we commit this fix?

aaliddell commented 4 weeks ago

This should be fixed in 5.0.0. Please let me know if not