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

Question: Already defined dependency makes buf generate failed #2715

Closed
boy-oo opened this issue Jan 19, 2024 · 1 comment
Closed

Question: Already defined dependency makes buf generate failed #2715

boy-oo opened this issue Jan 19, 2024 · 1 comment

Comments

@boy-oo
Copy link

boy-oo commented Jan 19, 2024

It looks like importing github.com/grpc-ecosystem/grpc-gateway/v2/runtime in the code makes buf return a warning. The warning that I receive looks like this:

...
protoc-gen-openapiv2/options/openapiv2.proto:719:7:symbol "grpc.gateway.protoc_gen_openapiv2.options.Scopes.ScopeEntry.key" already defined at vendor/github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options/openapiv2.proto:719:7
protoc-gen-openapiv2/options/openapiv2.proto:719:15:symbol "grpc.gateway.protoc_gen_openapiv2.options.Scopes.ScopeEntry.value" already defined at vendor/github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options/openapiv2.proto:719:15
protoc-gen-openapiv2/options/openapiv2.proto:719:23:symbol "grpc.gateway.protoc_gen_openapiv2.options.Scopes.ScopeEntry" already defined at vendor/github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options/openapiv2.proto:719:23
protoc-gen-openapiv2/options/openapiv2.proto:719:23:symbol "grpc.gateway.protoc_gen_openapiv2.options.Scopes.scope" already defined at vendor/github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options/openapiv2.proto:719:23

Is there any way to resolve this?

These are buf.yaml and buf.gen.yaml that I use:

# buf.yaml

version: v1
name: buf.build/my-squad/my-api
deps:
  - buf.build/googleapis/googleapis
  - buf.build/grpc-ecosystem/grpc-gateway
breaking:
  use:
    - FILE
lint:
  use:
    - DEFAULT
# buf.gen.yaml

version: v1
plugins:
  - plugin: go
    out: .
    opt:
      - paths=source_relative
  - plugin: go-grpc
    out: .
    opt:
      - paths=source_relative
  - plugin: grpc-gateway
    out: .
    opt:
      - paths=source_relative
      - generate_unbound_methods=true
  - plugin: openapiv2
    out: openapiv2
    opt:
      - use_go_templates=true
@bufdev
Copy link
Member

bufdev commented May 18, 2024

You will need to provide us a specific, reproducible example for us to investigate - for example, create a temporary github repository and provide the exact commands for us to reproduce your issue. However, it does appear that the issue is that you have .proto files vendored at vendor/github.com/grpc-ecosystem/grpc-gateway, while you are also depending on these files via the buf.build/grpc-ecosystem/grpc-gateway dependency, meaning that the compiler is finding these files twice (which is an error). You either need to exclude vendor https://buf.build/docs/configuration/v2/buf-yaml#excludes or you need to remove the dep.

Closing this issue as I think the resolution is relatively straightforward, but if you run into difficulty, feel free to reopen if you have a reproducible example for us to investigate!

@bufdev bufdev closed this as completed May 18, 2024
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

No branches or pull requests

2 participants