Skip to content
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

Error loading @rules_cc//cc:defs.bzl due to com_google_protobuf #274

Open
UebelAndre opened this issue Nov 15, 2024 · 5 comments
Open

Error loading @rules_cc//cc:defs.bzl due to com_google_protobuf #274

UebelAndre opened this issue Nov 15, 2024 · 5 comments

Comments

@UebelAndre
Copy link
Contributor

UebelAndre commented Nov 15, 2024

Description of the problem / feature request:

I just tried bumping to version 0.0.16 in rules_rust and ran into the following

rules_cc/cc/defs.bzl:16:6: Label '@@com_google_protobuf//bazel:cc_proto_library.bzl' is invalid because 'bazel' is not a package;

https://buildkite.com/bazel/rules-rust-rustlang/builds/12671#01933059-0247-44f6-88ed-b383c84ef6af

It seems inappropriate for rules_cc to be loading com_google_protobuf (at least in defs.bzl) and think it should be removed.

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

bazelbuild/rules_rust#3002

What operating system are you running Bazel on?

Linux, MacOS, Windows

What's the output of bazel info release?

release 7.3.2

What version of rules_cc do you use? Can you paste the workspace rule used to fetch rules_cc? What other relevant dependencies does your project have?

0.0.16

@UebelAndre UebelAndre changed the title Error loading @rules_cc//cc:defs.bzl Error loading @rules_cc//cc:defs.bzl due to com_google_protobuf Nov 15, 2024
@comius
Copy link
Collaborator

comius commented Nov 15, 2024

This is rather unfortunate, but the plan was for a long time that cc_proto_library would be in rules_cc. We introduced it into defs.bzl file and it got used. Now we need to keep it until the users migrate to cc_proto_library in com_google_protobuf.

I tried removing it. There's a releases 0.1.0 of rules_cc that doesn't have it in the defs.bzl file. But it breaks several important repos. For example grpc.

@UebelAndre
Copy link
Contributor Author

For backward compatibility, could cc_proto_library continue to be a re-export of the native rule? I like 0.1.0 but can see that that leads to build failures in com_google_protobuf which expects to find cc_proto_library at @rules_cc//cc:defs.bzl

@comius
Copy link
Collaborator

comius commented Nov 15, 2024

For backward compatibility, could cc_proto_library continue to be a re-export of the native rule? I like 0.1.0 but can see that that leads to build failures in com_google_protobuf which expects to find cc_proto_library at @rules_cc//cc:defs.bzl

There's no native cc_proto_library anymore in Bazel 8 and Bazel@HEAD, nothing to re-export.

What version of protobuf are you using, that does such an atrocity?

I suggest using Protobuf 28. and 29., first one has a redirect to the native rule available in Bazel <8. 29 (to be released soon) has a Starlark implementation of the rule. The latter ise compatible with Bazel 6,7 and 8.

Bazel 8 will load cc_proto_library from com_google_protobuf 29.0 automatically without the need for a load.

rules_proto are deprecated, but 7.x.x is a compatibility release, that points to protobuf 28.x+, so the migration may be more smooth.

defs.bzl files are deprecated and we should migrate away from them.

@UebelAndre
Copy link
Contributor Author

What version of protobuf are you using, that does such an atrocity?

I suggest using Protobuf 28. and 29., first one has a redirect to the native rule available in Bazel <8. 29 (to be released soon) has a Starlark implementation of the rule. The latter ise compatible with Bazel 6,7 and 8.

I think rules_rust is on 3.10.0. The last time I tried to upgrade I found myself in dependency hell from what appear like bzlmod related changes and ultimately couldn't get the new version to work without adding what seemed like a ton of dependencies.

defs.bzl files are deprecated and we should migrate away from them.

This sounds disappointing. It's very frustrating to need to hunt down all the unique ways to load rules from external repositories. @rules_<LANG>//<LANG>:defs.bzl was nice because quite a few rules use this pattern and it made loading rules easy.

That being said, neither of these topics feel relevant to rules_cc so don't want to distract too much more. If I can find a solution I'll report back. It'll likely require bumping protobuf.

@UebelAndre
Copy link
Contributor Author

Wow, this even goes into remote_java_tools

(20:00:48) ERROR: Traceback (most recent call last):
	File "/var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/ec321eb2cc2d0f8f91b676b6d4c66c29/external/remote_java_tools/BUILD", line 7, column 60, in <toplevel>
		load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library")
Error: file '@rules_cc//cc:defs.bzl' does not contain symbol 'cc_proto_library'

I don't think the 0.1.0 release will actually work. 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants