-
-
Notifications
You must be signed in to change notification settings - Fork 681
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
"cycle in dependency graph" when importing a go_repository #1322
Comments
FYI. if I add Too bad that go_repository does not have a 'build_file' attribute like |
I couldn't reproduce this. Are you using a recent version of rules_go and Gazelle? Here's the build file I see:
I'm working on an alternative to |
We're using bazel 0.10. and rules_go-0.9.0. FYI: this is what we have in the WORKSPACE:
and in our top-level BUILD.bazel:
We haven't switched to https://github.com/bazelbuild/bazel-gazelle, I'll try this next. Overriding the BUILD files for cases like this will be very useful to unblock people. |
After switching to use gazelle from https://github.com/bazelbuild/bazel-gazelle it fails differently: bazel build //...
ERROR: $HOME/.cache/bazel/_bazel_ensonic/556f802681b2087c6d9a6bcc3d0d954b/external/github_com_grpc_ecosystem_grpc_gateway/third_party/googleapis/google/api/BUILD.bazel:17:1: no such package '@github_com_grpc_ecosystem_grpc_gateway//google/api': BUILD file not found on package path and referenced by '@github_com_grpc_ecosystem_grpc_gateway//third_party/googleapis/google/api:annotations_go_proto'
ERROR: Analysis of target '//src/proto:registry_swagger' failed; build aborted: no such package '@github_com_grpc_ecosystem_grpc_gateway//google/api': BUILD file not found on package path
INFO: Elapsed time: 1.460s
FAILED: Build did NOT complete successfully (14 packages loaded) cat --number /usr/local/google/home/ensonic/.cache/bazel/_bazel_ensonic/556f802681b2087c6d9a6bcc3d0d954b/external/github_com_grpc_ecosystem_grpc_gateway/third_party/googleapis/google/api/BUILD.bazel
1 load("@io_bazel_rules_go//go:def.bzl", "go_library")
2 load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
3
4 proto_library(
5 name = "annotations_proto",
6 srcs = [
7 "annotations.proto",
8 "http.proto",
9 ],
10 visibility = ["//visibility:public"],
11 deps = [
12 "//google/api:api_proto",
13 "@com_google_protobuf//:descriptor_proto",
14 ],
15 )
16
17 go_proto_library(
18 name = "annotations_go_proto",
19 importpath = "google.golang.org/genproto/googleapis/api/annotations",
20 proto = ":annotations_proto",
21 visibility = ["//visibility:public"],
22 deps = [
23 "//google/api:go_default_library",
24 "@com_github_golang_protobuf//protoc-gen-go/descriptor:go_default_library",
25 ],
26 )
27
28 go_library(
29 name = "go_default_library",
30 embed = [":annotations_go_proto"],
31 importpath = "google.golang.org/genproto/googleapis/api/annotations",
32 visibility = ["//visibility:public"],
33 ) The dependency on line 23 looks wrong. |
Unfortunately, this is a known issue with vendored proto deps. See bazel-contrib/bazel-gazelle#33. Bazel interprets import paths in protos as being relative to the repository root. This means when a bunch of protos are vendored, they can't import each other. Related Bazel issues: bazelbuild/bazel#3867 and bazelbuild/bazel#4544. Until that's fixed, there's not much Gazelle can do to help. Gazelle will look for a |
I've been retrying it (with the gazelle part of rules_go and still at 0.9.0) - there is definitely a bug, it now creates a self edge:
generated BUILD file, see first 'options_proto' rule
I've tried switching to 0.10.1 with external gazelle again, but still have the problem with vendored deps. I've tried to sync my versions to the vendored version to no avail. |
The self-import bug was fixed in bazel-contrib/bazel-gazelle#52. Upgrading past that should resolve it. I'm hoping bazelbuild/bazel#4544 will let us fix the vendored proto problem. That will take some time though. |
Almost there! Now
and that yields
This looks like |
This seems like another flavor of the vendored proto problem. third_party/googleapis/google/api/annotations.proto imports "google/api/http.proto". I think this is meant to refer to http.proto in the same directory, but Bazel (and Gazelle) will interpret this relative to the root of the repository. In order for this to work correctly, that |
Works now. |
in my WORKSPACE:
and in my BUILD file
Now building:
The text was updated successfully, but these errors were encountered: