Expose the buf CLI as a supported target (@rules_buf_toolchains//:buf is not visible under Bazel 10)

Đang mở
#175 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
66/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Lĩnh vực
build-system

Hướng nghiên cứu

Start by reading the generated toolchains repository BUILD setup and the code that selects native_binary by operating system; the issue does not name those files. Check how the buf toolchain exposes its CLI and how existing executable targets are documented. Done means users have a supported, documented executable target for the downloaded buf CLI that works across platforms.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

There is currently no documented way to use the buf CLI downloaded by rules_buf as a tool, for example as the formatter in rules_multirun, a bazel run target or a genrule.
Users reach for @rules_buf_toolchains//:buf, but on Linux and macOS that label is a plain source file (the downloaded binary), and Bazel 10 stops that from working.

Request

Expose the buf CLI as a supported, documented executable target.
For example, always wrap it in native_binary (not just on Windows) and document it, or expose it from the rules_buf repo.

What breaks under Bazel 10

Bazel 10 no longer exports source files implicitly (--incompatible_no_implicit_file_export, see the file visibility proposal).
The generated rules_buf_toolchains repo sets default_visibility to public, but buf is only a source file on non-Windows platforms (native_binary is used only when os == "windows"), so it is not exported.
That is consistent with the proposal, so this is not a bug in itself.
It does show that depending on this label was never safe.

With rules_buf 0.6.1 and Bazel 10.0.0rc4:

alias(
    name = "buf",
    actual = "@rules_buf_toolchains//:buf",
)

bazel build //:buf fails with:

ERROR: in alias rule //:buf: Visibility error:
target '@@rules_buf++buf+rules_buf_toolchains//:buf' is not visible from target '//:buf'

The same build succeeds with --noincompatible_no_implicit_file_export, so the cause is the new default.

Options
  • Add a supported buf target (preferred).
  • As a minimal stopgap, add exports_files(["buf", "protoc-gen-buf-lint", "protoc-gen-buf-breaking"]) to the generated toolchains BUILD file, which makes the export explicit.
Workaround

Resolve the registered toolchain (@rules_buf//tools/buf:toolchain_type) in a small rule and expose its cli as an executable.

I could not find an existing issue about this.

Ngôn ngữ chính
Starlark
Star
64
Fork
41
Merge trung bình
3 giờ 49 phút
Pull request đã merge (30 ngày)
10

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của bufbuild/rules_buf

Tất cả issue của bufbuild/rules_buf

Issue tương tự

Thêm issue về Build System

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.