# 使用 Homebrew, Nix 安装 buildifier

查看 buildifier 的安装路径、可执行文件、元数据以及面向 AI 代理工作流的安全说明。

## 安装

```sh
sudo av install brew:buildifier
```

其他安装命令:

### macOS

- Homebrew (100%):

```sh
brew install buildifier
```

  证据: local Homebrew formula metadata

### Linux

- Nix (92%):

```sh
nix profile install nixpkgs#buildifier
```

  证据: nixpkgs package indexes: buildifier from https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/top-level/all-packages.nix

## 软件包事实

- **软件包键:** brew:buildifier
- **软件包管理器:** Homebrew
- **版本:** 8.5.1
- **来源摘要:** Format bazel BUILD files with a standard convention
- **主页:** <https://github.com/bazelbuild/buildtools>
- **仓库:** <https://github.com/bazelbuild/buildtools>
- **最后更新:** 2026-07-25T14:19:44-04:00
- **已生成:** 2026-08-03T19:37:03+00:00

## 可执行文件

- buildifier (别名)

## 安装行为

- Bottle: 不可用

## 版本和新鲜度

- 页面生成时间: 2026-08-03
- 管理器版本: 8.5.1
## 项目历史与用法

Buildifier is the Bazel ecosystem's standard formatter and linter for BUILD, WORKSPACE, MODULE.bazel, `.bzl`, and other Starlark-related files.

### 项目历史

Buildifier is part of the bazelbuild/buildtools repository, which collects developer tools for working with Google's Bazel build tool. The repository also includes related tools such as Buildozer and unused_deps.

Its role is deliberately analogous to source-code formatters such as clang-format: it gives Bazel and Starlark files a standard convention and can also report or fix lint warnings.

### 采用历史

Buildifier became common wherever Bazel is used seriously because BUILD and `.bzl` files are code-like inputs that benefit from deterministic formatting in review and CI. The tool is packaged by Homebrew and Nix according to the input and can also be installed with Go or run through Bazel rules.

Its adoption is tied directly to Bazel's adoption: monorepos and polyglot builds that standardize on Bazel often add Buildifier to presubmit checks so build metadata stays consistent.

### 使用方式

Basic usage is `buildifier path/to/file`; recursive formatting uses `buildifier -r path/to/dir`. The README documents file-type detection for BUILD, WORKSPACE, `.bzl`, MODULE, and default Starlark files, with `--type` overrides for stdin or unusual filenames.

The integrated linter runs with `--lint=warn` or `--lint=fix`, and machine-readable diagnostics are available with JSON output in check mode.

### 为什么软件包爱好者会关心

Buildifier is significant because it formats package/build metadata rather than application source. For Bazel users, BUILD files are the package graph, so a stable formatter lowers merge noise and makes automated rewrites safer.

It also sits beside Buildozer: Buildifier normalizes and checks files, while Buildozer edits them programmatically, together forming a small maintenance toolkit for large Bazel workspaces.

### 时间线

- 2010s: Buildifier developed inside the Bazel buildtools repository as Bazel's Starlark formatting tool.
- 2020s: buildtools releases continued through major versions and Buildifier gained broader linting and JSON diagnostic workflows.
- 2020s: Installation paths included Go module installation, Bazel rules, Homebrew, and Nix packages.

### Related projects

- Bazel is the build system whose BUILD, WORKSPACE, MODULE.bazel, and Starlark files Buildifier formats.
- Buildozer is the companion buildtools utility for command-line edits to Bazel files.
- unused_deps is another buildtools utility for Java dependency cleanup.

### 来源

- <https://github.com/bazelbuild/buildtools>
- <https://github.com/bazelbuild/buildtools/blob/main/buildifier/README.md>
- source_facts.package-manager


## 安全说明

narrow executable package without higher-risk signals.

- **Geiger 风险:** 绿色 / 低
- narrow executable package without higher-risk signals

## 其他软件包管理器记录

- Nix - buildifier: normalized package name match | nixpkgs package indexes: buildifier from https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/top-level/all-packages.nix


## Combined YAML source

View the package source record on GitHub. [combined/buildifier.yml](https://github.com/mxcl/pkgdb/blob/main/combined/buildifier.yml)


## 来源

- pkg.so package database
- Geiger risk classifier
- curated package history
- pkgdb category and tag curation
- external package-manager database matches
- cross-ecosystem install command graph
