MODULE.bazel

module(
  name = "proto_test"
)

bazel_dep(name = "grpc", version = "1.41.0", repo_name = "com_github_grpc_grpc")

BUILD:

load("@com_github_grpc_grpc//bazel:grpc_build_system.bzl", "grpc_proto_library")

grpc_proto_library(
    name = "rpc_proto",
    srcs = [
        "rpc.proto"
    ],
    use_external = True,
)

when I run command, error occurred, what should I do, thanks for any help!

bazel build :rpc_proto
ERROR: /tmp/BUILD:3:19: every rule of type _generate_cc implicitly depends upon the target '//external:protocol_compiler', but this target could not be found because of: no such target '//external:protocol_compiler': target 'protocol_compiler' not declared in package 'external' defined by /tmp/WORKSPACE (Tip: use `query "//external:*"` to see all the targets in that package)
1

There are 1 answers

0
Eugene On

gRPC does not support Bazel module builds at this time (1.41.0 is a really ancient version). You should setup the usual Bazel build and use more up-to-date gRPC version. Please consult this link:

http_archive(
    name = "com_github_grpc_grpc",
    urls = [
        "https://github.com/grpc/grpc/archive/YOUR_GRPC_COMMIT_SHA.tar.gz",
    ],
    strip_prefix = "grpc-YOUR_GRPC_COMMIT_SHA",
)
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
grpc_deps()
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
grpc_extra_deps()