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

Open
junghoahnsc opened this Issue Mar 16, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@junghoahnsc

junghoahnsc commented Mar 16, 2018

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

This comment has been minimized.

Contributor

jayconrod commented Mar 16, 2018

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

This comment has been minimized.

Contributor

jayconrod commented Mar 16, 2018

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

This comment has been minimized.

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