fix(ci): bust stale Homebrew glib cache on macOS runners#449
Open
tyvsmith wants to merge 1 commit into
Open
Conversation
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>
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.
Comment on lines
+54
to
+57
| echo "MACOS_LIB_VER=$(brew list --versions glib gtk4 libadwaita | tr '\n' '_')" >> "$GITHUB_ENV" | ||
| - uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| prefix-key: ${{ env.MACOS_LIB_VER }} |
Comment on lines
+55
to
+57
| - uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| prefix-key: ${{ env.MACOS_LIB_VER }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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