问题描述
从瞪羚生成的BUILD文件中,运行bazel build //foo/bar/protos/...:
时出现以下错误
ERROR: .../foo/bar/protos/BUILD.bazel:15:17: in deps attribute of go_proto_library rule //foo/bar/protos:protos_go_proto: '//baz/quux/api:api_proto' does not have mandatory providers: 'GoLibrary'
两个BUILD文件都具有:
load("@rules_proto//proto:defs.bzl","proto_library")
load("@io_bazel_rules_go//go:def.bzl","go_library")
load("@io_bazel_rules_go//proto:def.bzl","go_proto_library")
我见过https://github.com/bazelbuild/rules_go/blob/master/go/providers.rst
,但更令人困惑。
我也曾在Gophers Slack上问过这个问题,但那里的访问量很少。
解决方法
此错误意味着//baz/quux/api:api_proto
是deps
规则的go_proto_library
属性的目标种类错误(它没有“提供”正确的信息)。
//baz/quux/api:api_proto
可能是proto_library
的目标,并且应位于protos
属性中,而不是deps
属性中:
https://github.com/bazelbuild/rules_go/blob/master/proto/core.rst#go_proto_library