From 1d18dd6a4839df89d7ceaefce70563a8533fe366 Mon Sep 17 00:00:00 2001 From: "Oliver Surke (Gitea)" Date: Tue, 12 May 2026 11:52:24 +0200 Subject: [PATCH] fix: prevent brew bundle hanging on large cask installs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit HOMEBREW_NO_QUARANTINE=1 — skips the post-install xattr quarantine walk that Gatekeeper runs on every binary in the app bundle. For large apps like WhatsApp (237 MB, many nested binaries) this walk blocks for several minutes. Apps will show the standard one-time Gatekeeper dialog instead. HOMEBREW_NO_INSTALL_CLEANUP=1 — skips per-package cache cleanup after each install. A single brew cleanup already runs in ssr-sync afterwards. mdimport — now runs in background (&) so Spotlight indexing never blocks the restore flow. Co-authored-by: Cursor --- lib/brew.sh | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/brew.sh b/lib/brew.sh index b8424cb..8d763d9 100644 --- a/lib/brew.sh +++ b/lib/brew.sh @@ -141,17 +141,29 @@ ssr::brew::restore() { # prompt individually for each package that needs admin privileges. _ssr_sudo_keepalive_start - # Suppress per-app Spotlight indexing: mas would otherwise run mdimport - # after every App Store installation. One batch pass runs below instead. + # HOMEBREW_NO_QUARANTINE=1: skip the post-install `xattr -d com.apple.quarantine` + # pass that Homebrew runs on every cask. That xattr walk can block for + # several minutes on large apps (WhatsApp, Electron apps, …) because macOS + # Gatekeeper verifies every binary in the bundle. Apps will show a standard + # one-time Gatekeeper dialog on first launch instead — normal macOS behaviour. + # + # HOMEBREW_NO_INSTALL_CLEANUP=1: skip per-package cache cleanup after each + # install. A single `brew cleanup` runs in ssr-sync after the full bundle. + # + # MAS_NO_AUTO_INDEX=1: suppress per-app mdimport after every App Store app. + # One batch mdimport runs in the background below instead. local rc=0 - MAS_NO_AUTO_INDEX=1 brew bundle install --file="$brewfile" --verbose || rc=$? + HOMEBREW_NO_QUARANTINE=1 \ + HOMEBREW_NO_INSTALL_CLEANUP=1 \ + MAS_NO_AUTO_INDEX=1 \ + brew bundle install --file="$brewfile" --verbose || rc=$? _ssr_sudo_keepalive_stop - # Single batch Spotlight index of /Applications after all installs. - ssr::log "Indexing /Applications in Spotlight (one-time batch)" - mdimport /Applications 2>/dev/null || true - [[ -d "$HOME/Applications" ]] && mdimport "$HOME/Applications" 2>/dev/null || true + # Trigger Spotlight indexing in the background so it never blocks the restore. + ssr::log "Triggering background Spotlight index of /Applications" + mdimport /Applications &>/dev/null & + [[ -d "$HOME/Applications" ]] && mdimport "$HOME/Applications" &>/dev/null & if [[ $rc -ne 0 ]]; then ssr::warn "brew bundle install finished with errors (rc=$rc) — some packages were not installed."