Skip to content

Conversation

@meteorcloudy
Copy link
Member

@meteorcloudy meteorcloudy commented Jan 26, 2026

This addresses #28400.

Bazel 9 breaks usage of proto_library targets in @bazel_tools//src/main/protobuf because the BUILD file there loads rules and depends on repositories (like @grpc-java, @com_github_grpc_grpc, etc.) that are not visible from the @bazel_tools repository.

This change introduces src/main/protobuf/BUILD.tools, which will be used as the BUILD file for @bazel_tools//src/main/protobuf. This version:

  1. Only defines the proto_library targets, avoiding problematic loads and cross-repo dependencies.
  2. Adds alias targets for the language-specific targets (e.g., _java_proto) that were previously defined in the BUILD file.
  3. Points these aliases to a dedicated target that fails with a clear and helpful error message, explaining that language-specific proto targets are not available in @bazel_tools and users should generate their own code from the proto_library.

This ensures that users can still depend on the proto_library targets while providing a better experience for those attempting to use the unsupported language-specific targets.

@github-actions github-actions bot added the awaiting-review PR is awaiting review from an assigned reviewer label Jan 26, 2026
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request effectively addresses the problem of unclear error messages for unsupported language-specific proto targets by replacing deprecation warnings with explicit failures. The use of a genrule to provide a descriptive error message is a significant improvement for user experience, guiding developers on how to resolve the issue.

@meteorcloudy meteorcloudy changed the title Provide a better error message when using unsupported proto targets in @bazel_tools Support proto_library targets in @bazel_tools//src/main/protobuf Jan 26, 2026
Copy link
Collaborator

@fmeum fmeum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't provide an immediate benefit as long as Protobuf still depends on all the language rulesets, right?

If we already require folks to migrate their usage of some of these targets, I think that it would be better to move these protos out into their own module that still only provides the proto_library targets. It could be versioned together with Bazel and Bazel could even include a nodep to bump the version of the proto module.

@meteorcloudy
Copy link
Member Author

meteorcloudy commented Jan 26, 2026

I think that it would be better to move these protos out into their own module that still only provides the proto_library targets.

Yes, this is just a temporary fix that provides a better error message and makes the proto_library work again in Bazel 9.

I agree moving those to their own module should be the long term solution. But we need to figure out how to setup the modue (or modules?). Do you think we need to create a new github project or we can just publish it from the Bazel repo (pointing Bazel source archive)?

@fmeum
Copy link
Collaborator

fmeum commented Jan 26, 2026

We could release a module from a subdirectory and could even build a dedicated release archive in CI with just that subdirectory.

@meteorcloudy
Copy link
Member Author

How would the release artifacts be published? On the release page? I'm a bit worried confusing users with normal Bazel releases.

@fmeum
Copy link
Collaborator

fmeum commented Jan 26, 2026

As we would release together with a regular Bazel release, it could be just one more archive attached to a Bazel release. The Publish to BCR workflow can handle the subdirectory and the source.json template can point to the particular artifact.

@meteorcloudy meteorcloudy added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-review PR is awaiting review from an assigned reviewer labels Jan 26, 2026
@meteorcloudy
Copy link
Member Author

I'm thinking about other stuff in bazel_tools, for example, the C++ launcher binary. Probably need a more comprehensive plan for this. So let's make this change for now to stop the bleed. Filed #28434 to track the bigger issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants