瞪羚+ protobuf问题:没有强制性提供程序:'GoLibrary'

问题描述

从瞪羚生成的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_protodeps规则的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