Skip to content

Build fails with Bazel 9: proto_library and cc_proto_library not defined #192

@travisdowns

Description

@travisdowns

Problem

Building with Bazel 9 (the current default installed by bazelisk) fails because proto_library and cc_proto_library are no longer native rules in Bazel 9:

$ bazel build src:perf_to_profile
ERROR: /home/user/perf_data_converter/src/BUILD:170:1: name 'proto_library' is not defined
ERROR: /home/user/perf_data_converter/src/BUILD:175:1: name 'cc_proto_library' is not defined

This affects both src/BUILD (lines 170, 175) and src/quipper/BUILD (lines 23, 29, 35, 41, 47, 55) which use these rules without load() statements.

Root Cause

Bazel 9 removed proto_library and cc_proto_library from the set of natively available rules. They now need to be explicitly loaded, e.g.:

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

Similarly, src/quipper/BUILD uses cc_library, cc_binary, and cc_test without load() statements, which may also break in future Bazel versions.

Workaround

Adding a .bazelversion file with 8.2.1 pins bazelisk to Bazel 8 and restores a working build. See PR linked below.

Full Fix

The BUILD files should be updated to add explicit load() statements for all Starlark rules to be compatible with Bazel 9+.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions