fix: prevent brew bundle hanging on large cask installs
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 <cursoragent@cursor.com>
This commit is contained in:
+19
-7
@@ -141,17 +141,29 @@ ssr::brew::restore() {
|
|||||||
# prompt individually for each package that needs admin privileges.
|
# prompt individually for each package that needs admin privileges.
|
||||||
_ssr_sudo_keepalive_start
|
_ssr_sudo_keepalive_start
|
||||||
|
|
||||||
# Suppress per-app Spotlight indexing: mas would otherwise run mdimport
|
# HOMEBREW_NO_QUARANTINE=1: skip the post-install `xattr -d com.apple.quarantine`
|
||||||
# after every App Store installation. One batch pass runs below instead.
|
# 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
|
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
|
_ssr_sudo_keepalive_stop
|
||||||
|
|
||||||
# Single batch Spotlight index of /Applications after all installs.
|
# Trigger Spotlight indexing in the background so it never blocks the restore.
|
||||||
ssr::log "Indexing /Applications in Spotlight (one-time batch)"
|
ssr::log "Triggering background Spotlight index of /Applications"
|
||||||
mdimport /Applications 2>/dev/null || true
|
mdimport /Applications &>/dev/null &
|
||||||
[[ -d "$HOME/Applications" ]] && mdimport "$HOME/Applications" 2>/dev/null || true
|
[[ -d "$HOME/Applications" ]] && mdimport "$HOME/Applications" &>/dev/null &
|
||||||
|
|
||||||
if [[ $rc -ne 0 ]]; then
|
if [[ $rc -ne 0 ]]; then
|
||||||
ssr::warn "brew bundle install finished with errors (rc=$rc) — some packages were not installed."
|
ssr::warn "brew bundle install finished with errors (rc=$rc) — some packages were not installed."
|
||||||
|
|||||||
Reference in New Issue
Block a user