I have a repository where I'm using gazelle and proto build rules. My repository is structured like this:
WORKSPACE
\ proto
- user.proto
- user_service.proto
- BUILD
This is the BUILD
file I have inside my proto folder:
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_proto_grpc//go:defs.bzl", "go_proto_library")
package(default_visibility = ["//visibility:public"])
proto_library(
name = "user_proto",
srcs = ["user.proto"],
deps = [
"@com_google_protobuf//:timestamp_proto",
],
)
proto_library(
name = "user_service_proto",
srcs = ["user_service.proto"],
deps = [
":user_proto",
"@com_google_protobuf//:empty_proto",
],
)
go_proto_library(
name = "user_go_proto",
importpath = "github.com/abcd/user/proto",
protos = [":user_proto"],
)
go_proto_library(
name = "user_service_go_proto",
compilers = ["@io_bazel_rules_go//proto:go_grpc"],
importpath = "github.com/abcd/userservice/proto",
protos = [
":user_proto",
":user_service_proto",
],
)
This is my user.proto
file:
syntax = "proto3";
import "google/protobuf/timestamp.proto";
package some_package;
option go_package = "github.com/abcd/user/proto";
message User {
...
}
And this is my user_service.proto
file:
syntax = "proto3";
import "proto/user.proto";
import "google/protobuf/empty.proto";
package some_package;
option go_package = "github.com/abcd/userservice/proto";
service UserService {
...
}
I then run bazel build proto:all
and expect the go libraries to build successfully, but they do not.
Instead, I get an error stating that:
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
compilepkg: missing strict dependencies:
/private/var/tmp/_bazel_mohammednadeem/2fc3c21998c67019e72a996be754820f/sandbox/darwin-sandbox/581/execroot/__main__/bazel-out/darwin-fastbuild/bin/proto/user_service_go_proto_pb/github.com/abcd/userservice/proto/proto/user_service.pb.go: import of "github.com/abcd/user/proto"
No dependencies were provided.
Check that imports in Go sources match importpath attributes in deps.
I'm not really sure what's going on here. My importpaths look correct and I have the correct option go_package
set in the proto file.