Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import of github.com/gogo/protobuf/protoc-gen-gogo/descriptor, which is not a direct dependency #1385

Closed
junghoahnsc opened this issue Mar 16, 2018 · 3 comments · Fixed by #2529

Comments

@junghoahnsc
Copy link

Hello,

When I use gogoproto, I got the following error:

bazel-out/k8-fastbuild/bin/ranking/io/proto/linux_amd64_stripped/bigtable_proto_go~/xxx/proto/bigtable_proto_go/bigtable.pb.go: import of github.com/gogo/protobuf/protoc-gen-gogo/descriptor, which is not a direct dependency

Is this because wkt mapping is based on github.com/golang/protobuf not on gogoproto like
https://github.com/bazelbuild/rules_go/blob/master/proto/wkt/well_known_types.bzl#L10 ?

Thanks,

@jayconrod
Copy link
Contributor

Reproduced.

hello.proto

syntax = "proto3";

import "google/protobuf/descriptor.proto";

BUILD.bazel

load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")

proto_library(
    name = "hello_proto",
    srcs = ["hello.proto"],
    deps = ["@com_google_protobuf//:descriptor_proto"],
)

go_proto_library(
    name = "hello_go_proto",
    proto = ":hello_proto",
    compilers = ["@io_bazel_rules_go//proto:gogo_proto"],
    importpath = "example.com/repo2/hello",
)

@jayconrod
Copy link
Contributor

This is pretty much exactly because of the wkt mapping you pointed out. When we define the go_proto_compiler rules for gogo, we should set the deps list to be a list of libraries that provide the correct WKT import paths.

@robfig
Copy link
Contributor

robfig commented Sep 27, 2018

I'm running into this exact issue, but I'm not sure how to solve it. Do you have any advice or workaround?

This import in a proto:

import "google/protobuf/descriptor.proto";

plus this build rule

proto_library(
    name = "profiles_proto",
    srcs = ["extensions.proto"],
    deps = ["@com_google_protobuf//:descriptor_proto"],
)

go_proto_library(
    name = "profiles_go_proto",
    compilers = ["@io_bazel_rules_go//proto:gogo_proto"],
    importpath = "alpha/src/com/corp/profiles/protobuf",
    proto = ":profiles_proto",
)

generates this import statement in the .pb.go file:

import descriptor "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"

Resulting in the error message

GoCompile: missing strict dependencies:
	/private/var/tmp/_bazel_robfig/1db08896ecff7e5e96a745981c3b77e6/sandbox/darwin-sandbox/5/execroot/yext/bazel-out/darwin-fastbuild/bin/src/com/yext/profiles/protobuf/darwin_amd64_stripped/profiles_go_proto%/alpha/src/com/yext/profiles/protobuf/extensions.pb.go: import of "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
Known dependencies are:
	github.com/gogo/protobuf/gogoproto
	github.com/gogo/protobuf/proto
	github.com/gogo/protobuf/sortkeys
	github.com/gogo/protobuf/types
	github.com/golang/protobuf/ptypes/any
	google.golang.org/genproto/protobuf/api
	github.com/golang/protobuf/protoc-gen-go/plugin
	github.com/golang/protobuf/protoc-gen-go/descriptor
	github.com/golang/protobuf/ptypes/duration
	github.com/golang/protobuf/ptypes/empty
	google.golang.org/genproto/protobuf/field_mask
	google.golang.org/genproto/protobuf/source_context
	github.com/golang/protobuf/ptypes/struct
	github.com/golang/protobuf/ptypes/timestamp
	google.golang.org/genproto/protobuf/ptype
	github.com/golang/protobuf/ptypes/wrappers
Check that imports in Go sources match importpath attributes in deps.

WORKSPACE

load("@org_pubref_rules_protobuf//gogo:rules.bzl", "gogo_proto_repositories")

load("@bazel_gazelle//:deps.bzl", "go_repository")

# NOTE: I tried adding this, but it didn't seem to change anything
go_repository(
    name="com_github_gogo_protobuf",
    commit="1adfc126b41513cc696b209667c8656ea7aac67c",
    importpath="github.com/gogo/protobuf",
    build_file_proto_mode = "disable",
)

gogo_proto_repositories(
  excludes = [
    "com_google_protobuf",
    "org_golang_google_grpc",
    "com_github_gogo_protobuf",
  ]
)

Thank you for helping!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants