How to use `bazel cquery` to find out who brings an external dependency?

117 views Asked by At

My bazel build fails with the following error

link: package conflict error: github.com/golang/protobuf/ptypes/timestamp: multiple copies of package passed to linker:
    @io_bazel_rules_go//proto/wkt:timestamp_go_proto
    @com_github_golang_protobuf//ptypes/timestamp:timestamp
Set "importmap" to different paths or use 'bazel cquery' to ensure only one
package with this path is linked.

In the error message, I see use 'bazel cquery' to ensure only one package, how can I find out who brings/uses @com_github_golang_protobuf//ptypes/timestamp:timestamp using bazel cquery?

1

There are 1 answers

0
Mohammed On BEST ANSWER

Found the query

bazel cquery "somepath(//..., @com_github_golang_protobuf//ptypes/timestamp:timestamp)"