问题
I am trying to run a simple program with gRPC in dependency. I tried several examples but continuesly get the following error:
ERROR: /home/git/examples/WORKSPACE:1:1: name 'git_repository' is not defined
ERROR: Error evaluating WORKSPACE file
This is my bazel version:
➜ git:(master) ✗ bazel version
Build label: 0.23.2
And this is the workspace file content:
git_repository(
name = "com_github_grpc_grpc",
commit = "ac0808b107d73613191b66617a547a201871a845",
remote = "https://github.com/grpc/grpc.git",
)
load("@com_github_grpc_grpc//:bazel/grpc_deps.bzl", "grpc_deps")
grpc_deps()
bind(
name = "grpc_cpp_plugin",
actual = "@com_github_grpc_grpc//:grpc_cpp_plugin",
)
bind(
name = "grpc++_codegen_proto",
actual = "@com_github_grpc_grpc//:grpc++_codegen_proto",
)
Any help will be appreciated!
回答1:
git_repository
is no longer a native rule. You need to include it at the top of your WORKSPACE
with:
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
来源:https://stackoverflow.com/questions/55190124/solve-dependency-issue-when-using-grpc-cpp-in-bazel