-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bazel 4.0.0 - "ERROR: cc_toolchain does not have mandatory provider 'ProtoInfo'. " when building project with protobuf #12887
Comments
This is caused by an incompatible change that was flipped in Bazel 4.0.0: #11694 All you need to do to fix that issue is to upgrade either See also https://groups.google.com/g/bazel-discuss/c/gRGUbnpxkUU/m/JV4wZnm6AQAJ |
@Yannic upgrading |
Actually it looks like if both of these commits are applied (i.e. |
@bjacklyn out of curiosity, are you using prot_library native in your code or the one from rules_proto? Maybe that is the difference? |
@limdor -- I'm using
Which results in this error:
Updating to
But I'm trying to only upgrade bazel at the moment -- upgrading protobufs probably means upgrading a ton of other Which is why I'm using the workaround I found of applying those 2 commits mentioned above as patches:
|
Thanks @bjacklyn I'm on the same process like you. I updated rules_proto to the latest available in bazel mirror but unfortunately was not having commit |
I can confirm the same what @bjacklyn was saying, updating rules_proto only is not enough. I still do not have the information of which is the minimum version of com_google_protobuf that can be used applying cleanly the patches mentioned. If someone has this information would be very great to add it to this ticket. |
My guess is that an earlier version of For me, moving the rules_proto section high up in the WORKPACE file fixed the problem: git_repository(
name = "rules_proto",
commit = "cfdc2fa31879c0aebe31ce7702b1a9c8a4be02d2",
remote = "https://github.com/bazelbuild/rules_proto.git",
) |
It also looks like your WORKSPACE is missing the recommended
patch to fix:
|
protobuf_deps() is only available from protobuf 3.8.0. The question here is what is the minimum version of protobuf supported with Bazel 4 |
Just want to echo that the code snippet above does work... Just pulled this code down recently and the issue still exists in the code base so the above is needed to get that working. |
Upgrading protobuf has failed in #52853, this change is to work around issues in older protobuf versions for upgrading Bazel by cherry-picking two protobuf commits. See bazelbuild/bazel#12887 (comment) Commit 1: [bazel] Use proto_library targets to exclude WKPs from code-gen This prepares protobuf for a future release of Bazel which will make `ProtoInfo` mandatory for `proto_lang_toolchain.blacklisted_protos`. Commit 2: [bazel] Remove bootstrap hack from cc_proto_library and add interop with proto_library Bazel had a native `cc_proto_library` for more than 2 years now. This is the first step towards removing that rule from the Protobuf repo. PiperOrigin-RevId: 412892006 Change-Id: I424974d3f5be371d6b83d62fc24683cd84ff2585
On my macOS machine with Bazel 4.2.1, when I try to build, I get an immediate build error: ``` ERROR: /private/var/tmp/_bazel_t/12fcc22211704038f32f3c5236102e5e/external/com_google_protobuf/BUILD:979:21: in proto_lang_toolchain rule @com_google_protobuf//:cc_toolchain: '@com_google_protobuf//:cc_toolchain' does not have mandatory provider 'ProtoInfo'. ERROR: Analysis of target '//clusterers/ldd_clusterer:ldd-clusterer' failed; build aborted: Analysis of target '@com_google_protobuf//:cc_toolchain' failed ``` [Moving the `rules_proto` section higher in `WORKSPACE`](bazelbuild/bazel#12887 (comment)) fixes this issue on my machine. Building with this change on an Ubuntu 18.04 machine with Bazel 3 still works. (I still can't build on macOS because of `external/gbbs/gbbs/io.cc:20:11: error: use of undeclared identifier ‘M_MMAP_MAX’` but that's a separate issue.)
Hi, I found that just add below flags when you build with bazel-4.0 or above, everything will be fine.
|
Is there an update on this issue? I am also encountering the same error. |
Fantastic. I was trying to build scann. Wouldn't build with bazel 6, wouldn't build with bazel 5. Then I moved down to bazel 4, added this property and now it is building. This property was not recognized by bazel 5 and 6. |
so we can't upgrade to bazel 5 or 6 ? |
It does not work beyond bazel 5 because bazel does not support You should upgrade protobuf to higher version(maybe higher than 3.14.0, sorry I don't remeber the protobuf specified version), and remove the bazel compile flag |
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale. |
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:
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
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
?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.
The text was updated successfully, but these errors were encountered: