-
-
Notifications
You must be signed in to change notification settings - Fork 662
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
rules_go (or gazelle?) fails to resolve google/rpc/code.proto in com_github_googleapis_gax_go_v2 #3625
Comments
Tested with `bazel build --incompatible_disable_starlark_host_transitions //...`. Fixes #95. These aren't the newest rules_go/gazelle because of bazel-contrib/rules_go#3625.
I also tried updating to com_github_googleapis_gax_go_v2 2.12 (latest) but it didn't help. You can repro with:
EDIT: if you see |
Tested with `bazel build --incompatible_disable_starlark_host_transitions //...`. Fixes #95. These aren't the newest rules_go/gazelle because of bazel-contrib/rules_go#3625.
Just wanted to comment that I'm seeing the exact same thing - GAX is included as a transitive dependency of cloud.google.com/go/translate, and whatever is causing this is also likely causing my builds to fail. In the meantime until a patch comes out, I'm going to downgrade to 0.40.1 and 0.31.1. |
Could you try adding a Cc @linzhp |
Please read the release notes of rules_go 0.41 and Gazelle 0.32 for migration steps |
I had a similar issue. My bazel build uses pre-generated protobuf source files, so according to the docs, I had to add
|
The release notes overlook the case of a dependency on a third-party repo that depends on googleapis - unfortunately this probably affects a larger number of clueless maintainers like me.
I don't understand whether com_github_googleapis_gax_go_v2 is "importing Google APIs proto and generating Go code" or whether it should be. It was also not clear how/where to add these resolution directives. fmeum's comment adds the missing info (thank you) and suggests that I should tell go_repository to generate Go code. mpawlowski's comment implies that the go_repository does not need to generate the Go code, but that Gazelle's @fmeum Is |
However, when some proto files don't have pre-generated Go files, or the pre-generated files are out of sync with the proto files, but you need the Go packages, There are also cases when your own proto files need to import the proto files from other repos. Even though those proto to files come with pre-generated Go package, you still need to set |
Thank you for the explanation! Sounds like FYI, I tried to do it the way fmeum suggested, but it didn't work:
still fails with:
|
With Bzlmod, we have a registry of default |
This required a slightly tricky manual change to go_repositories.bzl: bazel-contrib/rules_go#3625 I also updated the Go dependencies trying to fix this, which didn't seem to be necessary but is probably worth doing regardless.
As you mentioned in the description of this issue, So this is what would be necessary:
This is assuming that you have the googleapis archive using the name
Also, |
@drigz The There are so many protos in Google APIs. If we provide all |
Thanks for clarifying, this is obvious in hindsight although I didn't realize it when reading the release notes or fmeum's comment. I guess the keywords "like the following" didn't jump out to me, sorry. It seems that https://github.com/bazelbuild/bazel-gazelle/blob/d2032781c7d4611ce778360ca345d86a97e06956/internal/bzlmod/default_gazelle_overrides.bzl would address the issue for brainless users who picked this up somewhere in a transitive dependency tree - @fmeum, should I send a PR? How can I test my change? |
You can add the directives to a local checkout of |
I gave this a try but gave up after failing to use MODULE.bazel or --override_repository (I added a syntax error into my local clone's root BUILD.bazel and ran |
I hit this trying to upgrade rules_go in order to upgrade to Go 1.21. I think the instructions could use a bit more hand-holding. I spent about 3 hours trying to upgrade. The sequence that ended up working for me:
My gazelle resolves ended up like:
I ended up with this:
Have any large commercial users migrated to bzlmod? It looks a lot nicer, but I'd rather not be the first to forge that path. |
For those using Bzlmod and struggling to resolve this manually (as I have been for many hours over the last couple days), adding the following to
I suppose this might be a useful addition to the registry of default build directives. |
…_overrides.bzl When updating to v0.32.0 anyone with a transient dependency on `github.com/googleapis/gax-go/v2` will need to add an override `gazelle:proto disable` directive. See here for discussion: bazel-contrib/rules_go#3625 (comment) Adding the directive as a default should prevent a bunch of manual effort.
…_overrides.bzl When updating to v0.32.0 anyone with a transient dependency on `github.com/googleapis/gax-go/v2` will need to add an override `gazelle:proto disable` directive. See here for discussion: bazel-contrib/rules_go#3625 (comment) Adding the directive as a default should prevent a bunch of manual effort.
This did the trick for me build_directives = [
"gazelle:resolve proto proto google/rpc/code.proto @googleapis//google/rpc:code_proto", # keep
"gazelle:resolve proto go google/rpc/code.proto @org_golang_google_genproto_googleapis_rpc//code", # keep
], |
…_overrides.bzl (#1623) * Add an entry for "github.com/googleapis/gax-go/v2" to default_gazelle_overrides.bzl When updating to v0.32.0 anyone with a transient dependency on `github.com/googleapis/gax-go/v2` will need to add an override `gazelle:proto disable` directive. See here for discussion: bazel-contrib/rules_go#3625 (comment) Adding the directive as a default should prevent a bunch of manual effort. * Update module lockfile
…_overrides.bzl (bazel-contrib#1623) * Add an entry for "github.com/googleapis/gax-go/v2" to default_gazelle_overrides.bzl When updating to v0.32.0 anyone with a transient dependency on `github.com/googleapis/gax-go/v2` will need to add an override `gazelle:proto disable` directive. See here for discussion: bazel-contrib/rules_go#3625 (comment) Adding the directive as a default should prevent a bunch of manual effort. * Update module lockfile
Workaround / Solution
See mpawlowski's solution or linzhp's explanation.
What version of rules_go are you using?
0.41.0
What version of gazelle are you using?
0.32.0
What version of Bazel are you using?
6.2.0
Does this issue reproduce with the latest releases of all the above?
I didn't try Bazel 6.2.1. rules_go and gazelle are latest. It does not reproduce with the previous releases, 0.40.1 and 0.31.1.
What operating system and processor architecture are you using?
Similar to Debian testing, x86.
Any other potentially useful information about your toolchain?
n/a
What did you do?
Updated to rules_go 0.41 and gazelle 0.32 and tried to build https://github.com/googlecloudrobotics/core.
What did you expect to see?
Build succeeds.
What did you see instead?
The error appears to be because code.proto is resolved incorrectly to
//google/rpc:code_proto
instead of to something inside@org_golang_google_genproto
as the release notes suggest.The text was updated successfully, but these errors were encountered: