Skip to content

The agent that grows with you

fix(installer): route macOS re-sign through the config-aware signing fixup

Brooklyn Nicholson456818875d35
diff --git a/scripts/install.sh b/scripts/install.sh
index 4449fb9151f..53daa95ddc3 100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -2990,16 +2990,41 @@ install_desktop() {
fi
fi
- # macOS: make the locally-built (ad-hoc) app relaunchable after an in-place
- # self-update. An ad-hoc bundle has no stable Designated Requirement, so a
- # later in-place rebuild (new cdhash) plus the inherited quarantine flag
- # trips Gatekeeper's tamper check ("Hermes is damaged and can't be opened").
- # Strip quarantine + re-apply a clean deep ad-hoc signature (no
- # hardened-runtime flag, which an ad-hoc build can't satisfy). Skipped when a
- # real signing identity is configured so a signed build isn't clobbered.
+ # macOS: route through the same config-aware signing fixup as
+ # `hermes desktop`, so install/repair and self-update agree about the app's
+ # identity. The fixup preserves the Electron entitlement plists and signs
+ # with a stable Designated Requirement (configured keychain identity, else
+ # identifier-pinned ad-hoc), so macOS TCC grants — Full Disk Access,
+ # Desktop/Downloads/Documents, Accessibility, microphone — survive the
+ # rebuild instead of resetting on every update. The shell's
+ # publisher-signing decision governed the build and is passed explicitly so
+ # importing Python cannot reverse it by loading HERMES_HOME/.env. If the
+ # helper is unavailable or fails, branch into the historical quarantine
+ # strip + deep ad-hoc repair so a broken venv never leaves the bundle
+ # unsigned/unlaunchable.
if [ "$OS" = "macos" ] && [ -z "${CSC_LINK:-}" ] && [ -z "${APPLE_SIGNING_IDENTITY:-}" ] && command -v codesign >/dev/null 2>&1; then
- xattr -cr "$app" 2>/dev/null || true
- codesign --force --deep --sign - "$app" >/dev/null 2>&1 || true
+ local config_python="$INSTALL_DIR/venv/bin/python"
+ local fixup_ok=""
+ if [ -x "$config_python" ]; then
+ if HERMES_HOME="$HERMES_HOME" "$config_python" - "$desktop_dir" <<'PYEOF'
+import sys
+from pathlib import Path
+from hermes_cli.main import _desktop_macos_relaunchable_fixup
+ok = _desktop_macos_relaunchable_fixup(
+ Path(sys.argv[1]), publisher_signing_configured=False
+)
+sys.exit(0 if ok else 1)
+PYEOF
+ then
+ fixup_ok=1
+ else
+ log_warn "Config-aware macOS signing fixup failed; applying the historical ad-hoc fallback."
+ fi
+ fi
+ if [ -z "$fixup_ok" ]; then
+ xattr -cr "$app" 2>/dev/null || true
+ codesign --force --deep --sign - "$app" >/dev/null 2>&1 || true
+ fi
fi
# `npm install` + `npm run pack` rewrite lockfiles; restore them so the