8000 Cannot build cc_proto_library on 29.4 with `ProtoLangToolchainInfo` not found, but py_proto_libray works. · Issue #258 · protocolbuffers/protocolbuffers.github.io · GitHub
[go: up one dir, main page]

Skip to content

Cannot build cc_proto_library on 29.4 with ProtoLangToolchainInfo not found, but py_proto_libray works. #258

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

Open
Guancheng-Li opened this issue May 31, 2025 · 0 comments

Comments

@Guancheng-Li
Copy link

I build cc_proto_library failed with the following error log:

bazel build --enable_workspace //experimental/liguancheng:person_cc_proto
ERROR: /home/liguancheng/workspace/parking_task_manager/experimental/liguancheng/BUILD:25:14: in @@com_google_protobuf//bazel/private:bazel_cc_proto_library.bzl%cc_proto_aspect aspect on proto_library rule //experimental/liguancheng:person_proto:
Traceback (most recent call last):
        File "/home/liguancheng/.cache/bazel/_bazel_liguancheng/8ea09798395bc4ee4983110cbef919ff/external/com_google_protobuf/bazel/private/bazel_cc_proto_library.bzl", line 57, column 48, in _aspect_impl
                proto_toolchain = toolchains.find_toolchain(ctx, "_aspect_cc_proto_toolchain", _CC_PROTO_TOOLCHAIN)
        File "/home/liguancheng/.cache/bazel/_bazel_liguancheng/8ea09798395bc4ee4983110cbef919ff/external/com_google_protobuf/bazel/private/toolchain_helpers.bzl", line 29, column 46, in _find_toolchain
                return getattr(ctx.attr, legacy_attr)[ProtoLangToolchainInfo]
Error: <target @@protobuf+//:cc_toolchain> (rule 'proto_lang_toolchain') doesn't contain declared provider 'ProtoLangToolchainInfo'
ERROR: Analysis of target '//experimental/liguancheng:person_proto' failed
ERROR: Analysis of target '//experimental/liguancheng:person_cc_proto' failed; build aborted

My WORKSPACE file is:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")


http_archive(
    name = "rules_pkg",
    urls = [
        "https://github.com/bazelbuild/rules_pkg/releases/download/1.1.0/rules_pkg-1.1.0.tar.gz",
    ],
    sha256 = "b7215c636f22c1849f1c3142c72f4b954bb12bb8dcf3cbe229ae6e69cc6479db",
)
load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
rules_pkg_dependencies()


http_archive(
    name = "com_google_protobuf",
    sha256 = "6bd9dcc91b17ef25c26adf86db71c67ec02431dc92e9589eaf82e22889230496",
    strip_prefix = "protobuf-29.4",
    urls = [
        "https://github.com/protocolbuffers/protobuf/releases/download/v29.4/protobuf-29.4.tar.gz",
    ],
)


http_archive(
    name = "rules_cc",
    urls = [
        "https://github.com/bazelbuild/rules_cc/releases/download/0.1.0/rules_cc-0.1.0.tar.gz",
    ],
    sha256 = "4b12149a041ddfb8306a8fd0e904e39d673552ce82e4296e96fac9cbf0780e59",
    strip_prefix = "rules_cc-0.1.0",
)
load("@rules_cc//cc:repositories.bzl", "rules_cc_toolchains")
rules_cc_toolchains()


http_archive(
    name = "rules_python",
    sha256 = "4f7e2aa1eb9aa722d96498f5ef514f426c1f55161c3c9ae628c857a7128ceb07",
    strip_prefix = "rules_python-1.0.0",
    urls = [
        "https://github.com/bazel-contrib/rules_python/releases/download/1.0.0/rules_python-1.0.0.tar.gz",
    ],
)
load("@rules_python//python:repositories.bzl", "py_repositories")
py_repositories()


http_archive(
    name = "rules_proto",
    sha256 = "14a225870ab4e91869652cfd69ef2028277fc1dc4910d65d353b62d6e0ae21f4",
    strip_prefix = "rules_proto-7.1.0",
    urls = [
        "https://github.com/bazelbuild/rules_proto/releases/download/7.1.0/rules_proto-7.1.0.tar.gz",
    ],
)
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies")
rules_proto_dependencies()


load("@rules_python//python:pip.bzl", "pip_parse")
pip_parse(
    name = "python_deps",
    requirements_lock = "//:requirements_lock.txt",
    extra_pip_args = [
        "--extra-index-url=https://mirrors.aliyun.com/pypi/simple",
    ],
)


load("@rules_python//python:repositories.bzl", "python_register_toolchains")
python_register_toolchains(
    name = "python3",
    python_version = "3.10",
)


load("@python_deps//:requirements.bzl", "install_deps")
install_deps()

My BUILD file is

load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")
load("@com_google_protobuf//bazel:cc_proto_library.bzl", "cc_proto_library")

package(default_visibility=["//visibility:public"])

proto_library(
    name = "person_proto",
    srcs = ["person.proto"],
)

py_proto_library(
    name = "person_py_proto",
    deps = [":person_proto"],
)

cc_proto_library(
    name = "person_cc_proto",
    deps = [":person_proto"],
)
@Guancheng-Li Guancheng-Li changed the title News Announcements for Version 29.x Cannot build cc_proto_library on 29.4 with ProtoLangToolchainInfo not found, but py_proto_libray works. May 31, 2025
@Guancheng-Li Guancheng-Li changed the title Cannot build cc_proto_library on 29.4 with ProtoLangToolchainInfo not found, but py_proto_libray works. Cannot build cc_proto_library on 29.4 with ProtoLangToolchainInfo not found, but py_proto_libray works. May 31, 2025
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

1 participant
0