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

[bazel.build] Problem with /reference/be/protocol-buffer #23611

Open
peytondmurray opened this issue Sep 12, 2024 · 1 comment
Open

[bazel.build] Problem with /reference/be/protocol-buffer #23611

peytondmurray opened this issue Sep 12, 2024 · 1 comment
Assignees
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Documentation Documentation improvements that cannot be directly linked to other team labels team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts type: documentation (cleanup)

Comments

@peytondmurray
Copy link

peytondmurray commented Sep 12, 2024

Page link:

https://bazel.build/reference/be/protocol-buffer

Problem description (include actual vs expected text, if applicable):

The https://github.com/bazelbuild/rules_proto/ repository is deprecated.

Where do you see this issue? (include link to specific section of the page, if applicable)

See this section: https://bazel.build/reference/be/protocol-buffer#proto_library

Any other information you'd like to share?

For what it's worth it's very hard for developers to come in and actually use bazel to build protocol buffers at the moment if they don't already have a working build. There is a lot of information in various places online which seems valid for old versions of protobuf; for example, many sources say that you can load the functions that generate code from protocol buffers using the following:

load("@com_google_protobuf//:protobuf.bzl", "cc_proto_library", "py_proto_library")

Now it seems that cc_proto_library is not available this way. I tried consulting the Bazel documentation but I don't actually think there's information about how to load cc_proto_library on the docs page. Furthermore if you look on the protocol buffers bazel docs they point you to the deprecated rules_proto repository. However in the readme for that repository, it says that the rules have been migrated to the protobuf repo, but if I search the docs in that repo there is no mention of cc_proto_library at all.

Looking in the protobuf repo examples directory, there is a usage of cc_proto_library which apparently you can load by doing

load("@com_google_protobuf//bazel:cc_proto_library.bzl", "cc_proto_library")

after you've done

http_archive(
    name = "com_google_protobuf",
    sha256 = "3b8bf6e96499a744bd014c60b58f797715a758093abf859f1d902194b8e1f8c9",
    strip_prefix = "protobuf-28.1",
    urls = ["https://github.com/protocolbuffers/protobuf/archive/v28.1.tar.gz"],
)
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

However there is a note about needing

# Needed because protobuf_deps brings rules_python 0.26.0 which is broken:
# https://github.com/bazelbuild/rules_python/issues/1543
http_archive(
    name = "rules_python",
    sha256 = "5868e73107a8e85d8f323806e60cad7283f34b32163ea6ff1020cf27abef6036",
    strip_prefix = "rules_python-0.25.0",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.25.0/rules_python-0.25.0.tar.gz",
)

However for the project I'm working on, I'm trying to update the (currently broken) build system so that it actually runs; unfortunately doing this leads to other build errors which look an awful lot like the cc_proto_library and py_proto_library APIs have changed.

Anyway, it's not really in the scope of this issue to fix all of this, but I just wanted to say that it's currently quite hard for new Bazel users to come in and actually find a path forward. This is exacerbated by the fact that in addition to managing project dependencies, developers are required to manually manage Bazel rule dependencies, as well as Bazel versions via Bazelisk. If there's any way to update the docs with a working example of how to generate python and C++ code from protocol buffers, I'd be super grateful.

@peytondmurray peytondmurray added team-Documentation Documentation improvements that cannot be directly linked to other team labels type: documentation (cleanup) untriaged labels Sep 12, 2024
@iancha1992 iancha1992 added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Sep 12, 2024
@meteorcloudy
Copy link
Member

/cc @comius

@meteorcloudy meteorcloudy added P2 We'll consider working on this in future. (Assignee optional) team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts and removed untriaged labels Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Documentation Documentation improvements that cannot be directly linked to other team labels team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts type: documentation (cleanup)
Projects
None yet
Development

No branches or pull requests

6 participants