Skip to content

ci: disable Swatinem/rust-cache cache-bin to fix macOS flake#48

Merged
mcarvin8 merged 1 commit into
mainfrom
cursor/rust-cache-disable-cache-bin
May 14, 2026
Merged

ci: disable Swatinem/rust-cache cache-bin to fix macOS flake#48
mcarvin8 merged 1 commit into
mainfrom
cursor/rust-cache-disable-cache-bin

Conversation

@mcarvin8
Copy link
Copy Markdown
Owner

Summary

Follow-up to PR46. The macOS test job is still hitting the same flake (e.g. https://github.com/mcarvin8/config-disassembler/actions/runs/25860900445/job/75990262606?pr=47):

error: unexpected argument 'test' found
Usage: rustup-init[EXE] [OPTIONS]

PR46 confirmed the toolchain install itself succeeds — the runner reports rustc 1.95.0 / cargo 1.95.0 immediately before tests. The failure happens in the next ~4s window, which is when Swatinem/rust-cache@v2 restores its cache.

Root cause

Swatinem/rust-cache@v2 defaults to cache-bin: true, which caches ~/.cargo/bin/. Its rustup-proxy exclusion is unreliable on macos-arm64 runners and can save the raw rustup-init binary into the cache. On a later run, the cache restore overwrites the freshly installed cargo proxy with that stale rustup-init, so the next cargo test resolves to rustup-init and exits 1.

This matches the user-observed "re-runs usually fix it" pattern: a healthy save can overwrite a poisoned one, but a single bad save then poisons every subsequent restore until the cache key changes (i.e. a Rust version bump).

Fix

Pass cache-bin: false to every Swatinem/rust-cache@v2 step in ci.yml (test/rustfmt/clippy/docs). The matrix has no installed bin tools worth caching:

  • macOS/Windows test jobs install nothing extra.
  • The ubuntu coverage path installs cargo-llvm-cov via taiki-e/install-action, which has its own caching.

mutation.yml and release-plz.yml are untouched — both are ubuntu-only and the mutation workflow benefits from caching the compiled cargo-mutants binary.

Test plan

`Swatinem/rust-cache@v2` defaults to `cache-bin: true`, which caches
`~/.cargo/bin/`. Its proxy-detection logic for the rustup shims is
unreliable on macos-arm64 hosted runners: it can save the `rustup-init`
proxy into the cache and, on a later run, restore that stale binary on
top of the freshly installed `cargo`. The next `cargo test` invocation
then resolves to `rustup-init` and fails with:

  error: unexpected argument 'test' found
  Usage: rustup-init[EXE] [OPTIONS]

Re-runs "usually" fix it because a healthy save can overwrite a poisoned
one, but a single bad save poisons every subsequent restore until the
cache key changes (i.e., a Rust version bump). PR46 (switching from
dtolnay/rust-toolchain to actions-rust-lang/setup-rust-toolchain) did
not address this — the toolchain step succeeds and is then clobbered by
the cache restore.

Disable `cache-bin` on every `Swatinem/rust-cache@v2` step in `ci.yml`
(test/rustfmt/clippy/docs). We have no installed bin tools worth caching
in any of these jobs — `cargo-llvm-cov` is installed via
`taiki-e/install-action`, which has its own caching. Leaves the
mutation workflow untouched (ubuntu-only and benefits from caching
`cargo-mutants`).

Co-authored-by: Cursor <cursoragent@cursor.com>
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mcarvin8 mcarvin8 merged commit d025cad into main May 14, 2026
7 checks passed
@mcarvin8 mcarvin8 deleted the cursor/rust-cache-disable-cache-bin branch May 14, 2026 12:58
@mcarvin8 mcarvin8 mentioned this pull request May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants