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

Expose bazel_deps to go_deps extension #1773

Closed
leungster opened this issue Apr 4, 2024 · 1 comment · Fixed by #1802
Closed

Expose bazel_deps to go_deps extension #1773

leungster opened this issue Apr 4, 2024 · 1 comment · Fixed by #1802

Comments

@leungster
Copy link

What version of gazelle are you using?

0.36.0

What version of rules_go are you using?

0.46.0

What version of Bazel are you using?

7.1.1

Does this issue reproduce with the latest releases of all the above?

Yes

What operating system and processor architecture are you using?

darwin arm64

What did you do?

I have a go dependency on https://github.com/grpc-ecosystem/grpc-gateway which has a proto dependency on googleapis.
In my repo, I added bazel_dep(name = "googleapis", version = "0.0.0-20240326-1c8d509c5") to my MODULE.bazel expecting that it would satisfy the dependency for grpc gateway. However, I'm getting the following error message.

ERROR: no such package '@@[unknown repo 'googleapis' requested from @@gazelle~~go_deps~com_github_grpc_ecosystem_grpc_gateway_v2]//google/api': The repository '@@[unknown repo 'googleapis' requested from @@gazelle~~go_deps~com_github_grpc_ecosystem_grpc_gateway_v2]' could not be resolved: No repository visible as '@googleapis' from repository '@@gazelle~~go_deps~com_github_grpc_ecosystem_grpc_gateway_v2'

Prior to bzlmod, I could declare googleapis in my WORKSPACE and go_repository targets would be able to use them.

My current work around is to patch gazelle to have a dependency on googleapis as described in this issue.

What did you expect to see?

@googleapis is a resolveable target from within go_deps.

What did you see instead?

@googleapis cannot be found unless it's a dependency within gazelle.

@leungster
Copy link
Author

Follow up. I got around needing to patch gazelle by turning on build_file_generation for grpc gateway.
Grpc gateway doesn't quite support bzlmod but it's defining an empty MODULE.bazel and not a WORKSPACE.bzlmod.
I'm guessing gazelle was defaulting to the repo's build files and isn't using WORKSPACE for declared dependencies.

My overrides look as followed.

go_deps.gazelle_override(
    build_file_generation = "on",
    directives = [
        "gazelle:go_generate_proto false",
        "gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor/apiconfig //internal/descriptor/apiconfig",
        "gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor/openapiconfig //internal/descriptor/openapiconfig",
        "gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options //protoc-gen-openapiv2/options",
    ],
    path = "github.com/grpc-ecosystem/grpc-gateway/v2",
)

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

Successfully merging a pull request may close this issue.

1 participant