fix(ci): bust stale Homebrew glib cache on macOS runners#449
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates the Rust CI workflow to improve cache correctness on macOS by incorporating native (Homebrew) library versions into the Rust cache key.
Changes:
- Adds a macOS-only step to record Homebrew native library versions into an environment variable.
- Reintroduces
Swatinem/rust-cache@v2, now configured with aprefix-keyderived from macOS library versions.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
890a1c8 to
6417e01
Compare
|
I'm not sure if this is a caching issue... I'm having the same issue when building locally atm |
6417e01 to
b276478
Compare
The Swatinem/rust-cache action was restored before brew installed the
native dependencies. When Homebrew updated glib (2.88.0 → newer) the
cached Rust build artifacts still referenced the old versioned Cellar
path (/opt/homebrew/Cellar/glib/2.88.0/lib), causing a linker failure:
ld: library 'gio-2.0' not found
Fix by:
1. Moving `brew install` before the rust-cache step so libs are current
before the cache is consulted.
2. Capturing `brew list --versions glib gtk4 libadwaita` into a
prefix-key so the cache key changes whenever those packages update,
forcing a clean Rust build with fresh pkg-config paths.
Linux and Windows cache behaviour is unchanged (MACOS_LIB_VER unset →
empty prefix-key → same default v0- prefix).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
b276478 to
4d350c5
Compare
Claude thinks it's still a caching issue, just happening locally too in addition to CI due to how homebrew records paths. Caveat that I didn't hit it locally.
|
|
Yeah that sounds reasonable. The fix also shouldn't break anything 👍 |
Problem
macOS CI jobs (
build macos-latest,test macos-latest) on multiple open PRs are failing with:Reproduces today on at least PRs #441, #445, and #448. main last ran 2026-05-19 (green, before the regression).
Cause
The workflow ran
Swatinem/rust-cache@v2beforebrew install gtk4 libadwaita imagemagick. When the runner had a previous cache hit, restored.rlibartifacts contained absolute paths to the Cellar version they were built against (e.g./opt/homebrew/Cellar/glib/2.88.0). Homebrew bumpedglibpast 2.88.0 between 2026-05-19 and 2026-05-26; that Cellar directory no longer exists on the runner, but the cached artifacts still reference it, causing the linker failure.Fix
Two small changes to the macOS job in
.github/workflows/rust.yml:brew installbeforerust-cacheso current library paths are present when cargo builds against the cached artifacts.prefix-key, so any future Homebrew bump ofglib/gtk4/libadwaitaautomatically invalidates the rust-cache instead of producing the same broken-path artifacts.MACOS_LIB_VERis unset on Linux/Windows, whereSwatinem/rust-cache@v2treats an emptyprefix-keyas the default, so other platforms are unaffected.Test plan
cargo build --release+cargo clippy --all-targets --release -- -D warningspass locally with the workflow change in place🤖 Generated with Claude Code