Skip to content

Challenges integrating with rules_buf #117

@michaelloehnig

Description

@michaelloehnig

My team and I are evaluating rules_buf for our project and have run into several integration challenges. Would love to get some clarity on the current capabilities and recommendation.

Workspace setup

  • Multiple proto trees with different import paths
    • example: directory: /service/common/common.proto import path: company.com/sub//service/common
  • Existing Bazel build setup with gazelle directives
  • A preference to avoid publishing to BSR for dependency management

Questions/Issues

1. Dependency Management Without BSR

The Buf documentation states that dependencies must be published to BSR:

The value must be a valid path to a BSR module (either the public BSR at buf.build or a private BSR instance). It can't be a local Git reference to a buf.yaml file or a URL path to a Git repo.

Question: Is there any support for local dependencies or workspace-style setups? We have multiple proto modules in the same repo that need to reference each other, but we'd prefer not to publish internal modules to BSR.

2. Gazelle Integration and Ignore Patterns

Questions:

  • Does rules_buf respect gazelle:resolve directives for controlling dependency resolution?
  • How does it interact with .bazelignore files? We need certain directories to be excluded from processing.

3. Multi-Module Repo Support

Since we have multiple proto trees with different import paths:

  • Can rules_buf handle multiple buf modules in a single repository?
  • What's the recommended approach for this kind of setup?

Example: We have a repository structure like:

/core      # Contains foundational proto definitions (separate bzlmod module)
/service   # Contains service-specific protos that import from /core

Where the /service protos have imports like:

import "core/types/common.proto";
import "core/config/settings.proto";

Currently, each directory only contains Bazel BUILD files with proto_library definitions - there are no buf.yaml files in these directories yet. The /core directory is configured as a separate bzlmod module, and the /service protos depend on definitions from /core, but we need both to be built together in the same repository without publishing /core to BSR as an external dependency.

4. Well-Known Types Import Resolution

We're encountering errors for standard protobuf types when running bazel run //:buf_breaking:

system error: proto: could not resolve import "google/protobuf/timestamp.proto": not found

Questions:

  • How should well-known types (like google/protobuf/*) be handled in rules_buf? From our understanding this should work out the box.
  • Are there dependencies or buf modules that need to be explicitly declared for well-known types?

Any guidance, examples, or documentation pointers would be greatly appreciated! Happy to provide more specific details about our setup if that would help.

Thanks!

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