gazelle+protobuf problem: does not have mandatory providers: 'GoLibrary'

2.3k views Asked by At

From gazelle-generated BUILD files, I get the following error when I run 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'

Both BUILD files have:

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")

I have seen https://github.com/bazelbuild/rules_go/blob/master/go/providers.rst, but it was more confusing.

I also asked this on the Gophers Slack, but there is very little traffic there.

1

There are 1 answers

0
Sjoerd Visscher On BEST ANSWER

This error means that //baz/quux/api:api_proto is the wrong kind of target for the deps attribute of the go_proto_library rule (it does not "provide" the right information).

//baz/quux/api:api_proto is probably a proto_library target, and should be in the protos attribute instead of the deps attribute: https://github.com/bazelbuild/rules_go/blob/master/proto/core.rst#go_proto_library