opened
levimm
username_0
<!-- Please answer these questions before submitting your issue. Thanks! -->

### What version of gazelle are you using?
0.18.1
<!-- Check bazel_gazelle in WORKSPACE if you're not sure -->

### What version of rules_go are you using?
0.19.3
<!-- Check io_bazel_rules_go in WORKSPACE if you're not sure -->

### What version of Bazel are you using?
0.28.1
<!-- Run "bazel version" to find out -->

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


### What operating system and processor architecture are you using?
darwin


### What did you do?
My project is using dep and it imports both k8s.io/kubernetes/xxx and k8s.io/apimachinery/xxx packages. I setup WORKSPACE and BUILD.bazel following to readme. Then I run "bazel run //:gazelle", and I got a lot of disambiguate message.
`gazelle: rule //vendor/k8s.io/kubernetes/test/utils:go_default_library imports "k8s.io/apimachinery/pkg/watch" which matches multiple rules: //vendor/k8s.io/apimachinery/pkg/watch:go_default_library and //vendor/k8s.io/kubernetes/staging/src/k8s.io/apimachinery/pkg/watch:go_default_library. # gazelle:resolve may be used to disambiguate
`
I can add gazelle:resolve for this specific package but there're a lot of them. Does it mean I need to add rules for every of them? Is there a way to match multiple package at once?
<!--
If possible, provide a minimal recipe for reproducing the error.
-->

### What did you expect to see?
`bazel run //:gazelle` works without errors


### What did you see instead?
`gazelle: rule //vendor/k8s.io/kubernetes/test/utils:go_default_library imports "k8s.io/apimachinery/pkg/watch" which matches multiple rules: //vendor/k8s.io/apimachinery/pkg/watch:go_default_library and //vendor/k8s.io/kubernetes/staging/src/k8s.io/apimachinery/pkg/watch:go_default_library. # gazelle:resolve may be used to disambiguate
`
Too many disambiguate when import k8s.io/apimachinery package
issue
created
jayconrod
username_1
This error comes up when there are multiple libraries in the same repository with the same import path. You can use `# gazelle:resolve` to fix individual cases, but you should really remove one of the copies.

The main Kubernetes repository has a `staging` directory where code for other projects like `k8s.io/apimachinery` is developed. That code is mirrored out to `k8s.io/apimachinery` automatically. I don't think `staging` has any purpose other than development; it's certainly not intended for packages in the `staging` directory to be imported directly. I'd suggest deleting `vendor/k8s.io/kubernetes/staging` entirely from your project.
comment
created
r351574nc3
username_2
@username_1 What about in cases where source code is generated like with protobuf? In this case, it's not a matter of removing a copy. How should that situation be handled instead?
comment
created
jayconrod
username_1
@username_2 If code is generated with `go_proto_library`, that can be resolved by Gazelle as a normal library.

I'm not sure I have enough information to answer your question though? Feel free to open a new issue. I'll close this one since it's been answered.
comment
closed
jayconrod
username_1
issue