Skip to content

fix(ci): bust stale Homebrew glib cache on macOS runners#449

Open
tyvsmith wants to merge 1 commit into
feschber:mainfrom
tyvsmith:fix/ci-macos-rust-cache-glib
Open

fix(ci): bust stale Homebrew glib cache on macOS runners#449
tyvsmith wants to merge 1 commit into
feschber:mainfrom
tyvsmith:fix/ci-macos-rust-cache-glib

Conversation

@tyvsmith
Copy link
Copy Markdown
Contributor

@tyvsmith tyvsmith commented May 27, 2026

Problem

macOS CI jobs (build macos-latest, test macos-latest) on multiple open PRs are failing with:

ld: warning: search path '/opt/homebrew/Cellar/glib/2.88.0/lib' not found
ld: library 'gio-2.0' not found
clang: error: linker command failed with exit code 1

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@v2 before brew install gtk4 libadwaita imagemagick. When the runner had a previous cache hit, restored .rlib artifacts contained absolute paths to the Cellar version they were built against (e.g. /opt/homebrew/Cellar/glib/2.88.0). Homebrew bumped glib past 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:

  1. Run brew install before rust-cache so current library paths are present when cargo builds against the cached artifacts.
  2. Key the cache on the installed Homebrew library versions via prefix-key, so any future Homebrew bump of glib / gtk4 / libadwaita automatically invalidates the rust-cache instead of producing the same broken-path artifacts.

MACOS_LIB_VER is unset on Linux/Windows, where Swatinem/rust-cache@v2 treats an empty prefix-key as the default, so other platforms are unaffected.

Test plan

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings May 27, 2026 00:05
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 a prefix-key derived 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 }}
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