如何使用`bazel cquery`来查找引入外部依赖项的模块?

huangapple go评论77阅读模式
英文:

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

问题

我的bazel构建失败,出现以下错误:

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.

在错误消息中,我看到use 'bazel cquery' to ensure only one package,我如何使用bazel cquery找出是谁引入/使用了@com_github_golang_protobuf//ptypes/timestamp:timestamp

英文:

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

得分: 1

找到了查询

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

Found the query

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

huangapple
  • 本文由 发表于 2023年7月19日 23:09:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/76722751.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定