mr-boxington README

项目的 README,来自 github.com/jdx/mr-boxington。合并为一个 markdown 文件:README.md。

Mr Boxington, a cardboard cache box with a monocle and a handlebar mustache

mr boxington

A shared cache. A tidier target/.
Reuse Cargo builds across worktrees, keep disk use in check, and run builds together.

Get started · Documentation · Benchmarks · Releases

mbx is a build cache for Rust projects. Cargo still resolves dependencies, plans builds, and runs your tools. mbx restores matching compiler outputs from one shared store and compiles the rest. Each command starts its own cache agent and stops it when the build ends; there is no daemon to manage.

Get started

With mise:

mise use --global --tool-option mr_boxington=true rust mr-boxington

Or with Cargo:

cargo install mbx --locked
mbx setup

With mise 2026.9.2 or newer, the mr_boxington Rust option wraps Cargo without an mbx setup hook. Open a shell with mise activation or shims on PATH, check Cargo's path, and use Cargo normally:

cargo build
cargo test --workspace --all-features
cargo clippy --workspace --all-targets -- -D warnings

Interactive builds use cargo-pretty's display by romancitodev, extended with mbx cache information. Follow live and completed crates, browse warnings and test failures, and see cache hits, misses, bypasses, and estimated compiler time saved. The build bar doubles as a cache breakdown: green for hits, yellow for misses, and grey for bypasses and compilations not looked up.

Cargo remains in charge of run, tests, doctests, and configured runners. CI, redirected output, and explicit output formats keep Cargo's normal output. Set MBX_DISPLAY=plain, or run mbx settings set display plain, to turn the display off.

A real mixed-cache rebuild after a shared-source edit, with per-crate outcomes

View the still image.

To try mbx without automatic wrapping, install it and run mbx build directly. For coding agents and other non-interactive tools, use mise exec -- cargo build or put mise's shims on their PATH. The setup guide covers desktop applications and standalone setup with the Cargo shim. For mise older than 2026.9.2, see Older mise versions.

Verified release archives are available for Linux, macOS, and Windows. All installation options →

What you get

A cold store needs a build to fill it. Unsupported invocations run normally without caching, and restored debug information can retain the original checkout's paths. See how it works and the caching limits.

Use it in GitHub Actions

permissions:
  contents: read

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: jdx/mr-boxington-action@v1
      - run: mbx test --workspace

Install your chosen Rust toolchain before the cache action. The action's default github backend restores a pruned Cargo target directory and registry from the GitHub Actions cache. It saves a new entry after a successful run for a push to the default branch. Pull requests only restore, unless you set save-on-pull-request to let same-repository pull requests save entries of their own; pull requests from forks never save. See the GitHub Action guide for complete workflows, parallel builds, remote caches, and release policy.

Inspect and maintain the cache

mbx doctor                   # check tools, setup, and cache access
mbx tui                      # watch builds using this cache
mbx stats                    # report lifetime savings and workspace sharing
mbx explain --last           # explain the last recorded build
mbx cache stats              # summarize the store, managed targets, and incremental state
mbx gc --dry-run             # preview collection
mbx clean                    # remove this workspace's managed target
mbx clean --under /tmp/run   # remove recorded workspaces beneath a deleted root
mbx adopt --recursive ~/src  # adopt existing target directories without deleting outputs

On a filesystem that supports reflinks, restored outputs share data blocks with the store until modified. Elsewhere, mbx hard links the read-only store object into place by default. It copies bytes on Windows, when it cannot link, or with restore_hardlink = false. See output restoration.

Run mbx adopt to turn existing target/ directories into managed targets without deleting their contents. A build outside CI does the same for its own checkout. Understand managed targets →

Find your next step

Task Guide
Set up editors, watchers, and worktrees Local development
Change budgets or build policy Configuration
Choose mold, Wild, or toolchain LLD Managed linkers
Share work across CI runners Remote cache
Cache make or CMake builds Standalone C and C++
Investigate an unexpected result Troubleshooting
Look up a command CLI reference

Contribute

See CONTRIBUTING.md for development setup, documentation checks, tests, and pull request conventions. Ask questions in Discussions; report suspected vulnerabilities through the private process in SECURITY.md.

mbx builds on Cargo and on ideas from sccache and kache; kache directly inspired its design. See Acknowledgements.

License

MIT

mr-boxington (jdx/mr-boxington)

正在搜索数据库…

这是做什么用的?mbx 是一个 Rust 项目的构建缓存。Cargo 仍然负责解析依赖、规划构建并运行你的各种工具;mbx 则从一份共享存储中恢复匹配的编译产物,只重新编译剩下的部分。
它是替代 Cargo 的,还是和 Cargo 一起用的?它是在 Cargo 之上运行的,并不是要取代 Cargo。每条命令都会启动自己的缓存代理,构建结束后将其停止——没有任何需要你管理的后台守护进程。
每次构建都能命中缓存吗?不能。存储为空时需要先构建一次来填充;遇到不支持的调用方式会直接不带缓存地运行;另外恢复出来的调试信息可能会保留原始代码目录的路径。
除了 Rust 项目,它还能缓存别的吗?可以,文档里提供了针对 C 和 C++ 构建的独立模式,涵盖 make 和 CMake。
我怎么知道这次构建为什么没命中缓存?运行 mbx explain --last:命中、未命中、无法查询和跳过缓存的情况都会分别统计,方便你排查构建问题。
mbx 的灵感来自哪里?它构建在 Cargo 之上,并借鉴了 sccache 和 kache,作者也说明这两者直接启发了它的设计。
它会动我已有的 target/ 文件夹吗?只有在你确认提示之后,才会替换已有的真实 target/ 目录。在支持 reflink 的文件系统上,恢复出的产物在修改前甚至会与共享存储共用同一份数据块。
作者
jdx
大小
24 MB
星标
778
时长
3个月
提交 · 90 天