You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When building my project I got the following error:
ERROR: /home/jean-philippe/.cache/bazel/_bazel_jean-philippe/9311bf9c1e6a8c241086a78e85d9d27b/external/com_github_nats_io_go_nats_streaming/pb/BUILD.bazel:11:1: no such package '@com_github_nats_io_go_nats_streaming//github.com/gogo/protobuf/gogoproto': BUILD file not found on package path and referenced by '@com_github_nats_io_go_nats_streaming//pb:pb_go_proto'
ERROR: Analysis of target '//api/handler:go_default_test' failed; build aborted: no such package '@com_github_nats_io_go_nats_streaming//github.com/gogo/protobuf/gogoproto': BUILD file not found on package path
INFO: Elapsed time: 0.215s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
When I check the content of the BUILD.bazel file in the error message everything looks good to me
As this file gets generated and I only added the dependency to the project I'm a bit lost what the issue might be here and I would like to sort out if it's an issue in my approach of doing things or perhaps a bug.
What seems a bit wrong to me is this import path in the error message @com_github_nats_io_go_nats_streaming//github.com/gogo/protobuf/gogoproto I'm not sure if this is right.
I imported all my dependencies and created the buildfiles using gazelle.
The text was updated successfully, but these errors were encountered:
The issue, as you pointed out, is the dependencies are wrong. protocol.proto imports github.com/gogo/protobuf/gogoproto/gogo.proto. Bazel interprets proto imports relative to repository roots (you can think of it passing -I<repo> for each repository). This won't work, since with gogo, you'll have gogoproto/gogo.proto, not github.com/gogo/protobuf/gogoproto/gogo.proto. So unfortunately, there's no correct way to express the dependency right now.
bazelbuild/bazel#3867 is a Bazel feature request to let proto_library set the root directory for imports. Ideally, we would have something like include_prefix and strip_include_prefix in cc_library.
Until then, I'd recommend using the pre-generated .pb.go files from this repository, rather than building proto files at run-time. You can do that in go_repository by setting build_file_proto_mode = "disable".
Note that there are a number of other issues with proto dependencies. #1548 is a plan to fix them.
@jayconrod thank you for your answer and detailed clarification in #1548. I build successfully my project by setting the proto mode to disable like you suggested.
I have this go repository as a dependency in my project https://github.com/nats-io/go-nats-streaming
When building my project I got the following error:
When I check the content of the
BUILD.bazel
file in the error message everything looks good to meAs this file gets generated and I only added the dependency to the project I'm a bit lost what the issue might be here and I would like to sort out if it's an issue in my approach of doing things or perhaps a bug.
What seems a bit wrong to me is this import path in the error message
@com_github_nats_io_go_nats_streaming//github.com/gogo/protobuf/gogoproto
I'm not sure if this is right.I imported all my dependencies and created the buildfiles using gazelle.
The text was updated successfully, but these errors were encountered: