bazel: bazel 4.0.0 - "ERROR: cc_toolchain does not have mandatory provider 'ProtoInfo'. " when building project with protobuf

Description of the problem / feature request:

I am developing a Paragraph framework that builds with bazel and depends on protobuf. After updating bazel to version 4.0.0 I got an error:

ERROR: /usr/local/google/home/misaev/.cache/bazel/_bazel_misaev/c13aabee7e17f0c08e7db24fb9d21398/external/com_google_protobuf/BUILD:975:21: in proto_lang_toolchain rule @com_google_protobuf//:cc_toolchain: '@com_google_protobuf//:cc_toolchain' does not have mandatory provider 'ProtoInfo'.

The issue appeared only after bazel was updated, the issue disappears if bazel is downgraded to the version 3.7.2. It’s possible the issue is with protobuf itself and/or rules_proto, but since the error is fixed with downgrading, I assume this is a reasonable place for a bug description.

Bugs: what’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

The simplest way is

  1. clone paragraph
git clone git@github.com:google/paragraph.git
cd paragraph/
  1. checkout initial commit that does not have dependency on Tensorflow (hence it’s apparent the issue is with combination of bazel and rules_proto/protobuf)
git checkout db503f48fabbac47fe9a597feacb7be2226b6832
  1. build it and it fails
bazel test ...

What operating system are you running Bazel on?

Linux 5.7.17-1rodete4-amd64 #1 SMP Debian 5.7.17-1rodete4 (2020-10-01) x86_64 GNU/Linux

What’s the output of bazel info release?

misaev@misaev2:~/dev/paragraph$ bazel info release
release 4.0.0

Have you found anything relevant by searching the web?

Yes, it looks like Tensorflow had similar issues yesterday updating to bazel 4.0.0 and shortly after that performing a rollback. Paragraph pretty much only depends on protobuf (through rules_proto) and abseil, so it should be more convenient to use it as a minimally failing example.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 5
  • Comments: 16 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Hi, I found that just add below flags when you build with bazel-4.0 or above, everything will be fine.

build --incompatible_blacklisted_protos_requires_proto_info=false

This is caused by an incompatible change that was flipped in Bazel 4.0.0: https://github.com/bazelbuild/bazel/issues/11694

All you need to do to fix that issue is to upgrade either rules_proto to at least cfdc2fa31879c0aebe31ce7702b1a9c8a4be02d2 or make sure you use at least Protobuf 3.13 in you build.

See also https://groups.google.com/g/bazel-discuss/c/gRGUbnpxkUU/m/JV4wZnm6AQAJ