stackb / rules_proto

Bazel build rules for protobuf / gRPC (now with gazelle)
Apache License 2.0
272 stars 148 forks source link

error loading package '@build_stack_rules_proto//': cannot load '//rules:proto_gazelle.bzl' #369

Open jbedard opened 6 months ago

jbedard commented 6 months ago
ERROR: /.../external/build_stack_rules_proto/plugin/bufbuild/BUILD.bazel:5:29: error loading package '@build_stack_rules_proto//': cannot load '//rules:proto_gazelle.bzl': no such file and referenced by '@build_stack_rules_proto//plugin/bufbuild:protoc-gen-es'
ERROR: Analysis of target '//local/package/not/using/rules_proto failed; build aborted:

It seems to be from this load statement. Patching that statement to include the @build_stack_rules_proto// fixes it for me locally.

diff --git a/BUILD.bazel b/BUILD.bazel
index 006a1149..34a55a00 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -1,7 +1,7 @@
 load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
 load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
 load("@npm_ts_proto//:defs.bzl", "npm_link_all_packages")
-load("@//rules:proto_gazelle.bzl", "proto_gazelle")
+load("@build_stack_rules_proto//rules:proto_gazelle.bzl", "proto_gazelle")

 exports_files(["rules_proto_config.yaml"])

I can open a PR but haven't had time to actually reproduce it outside my private repo. I don't think I'm doing anything unique so I'm not sure why this hasn't been seen elsewhere?

sacsar commented 6 months ago

I have also hit this (again in a private repo) with Bazel 7.1.0. Are you using bzlmod? (I wonder if the meaning of @// changed.)

jbedard commented 6 months ago

Yes, this is with bzlmod.

jvolkman commented 3 months ago

Doesn't "@//" mean the main repo? Shouldn't this just be "//rules:proto_gazelle.bzl"?