Skip to content

fix(rosetta2): detect Rosetta 2, route brew through arch -arm64, add notice card - #169

Open
msitarzewski wants to merge 2 commits into
mainfrom
fix/rosetta2-arch-detection
Open

fix(rosetta2): detect Rosetta 2, route brew through arch -arm64, add notice card#169
msitarzewski wants to merge 2 commits into
mainfrom
fix/rosetta2-arch-detection

Conversation

@msitarzewski

Copy link
Copy Markdown
Owner

What & why

Fixes #158Error: Cannot install under Rosetta 2 in ARM default prefix on Apple Silicon. A translated (x86_64) build of the app spawning arm-native brew at /opt/homebrew is rejected by Homebrew. Apple is winding Rosetta 2 down (largely ends macOS 28), so this hardens detection and keeps brew working when the app is running translated.

Approach (both shells)

Runtime detection, not compile-time. Uses sysctl.proc_translated (1 = translated), because an x86_64 build cannot see its own translation via #if arch(...) / cfg!(target_arch).

  1. Detectis_translated() / SystemProfile.isTranslated(), cached; honors BREWBROWSER_FAKE_ROSETTA=1 for QA.
  2. Bridge — when translated and the brew prefix is /opt/homebrew, spawn brew via /usr/bin/arch -arm64 <brew> <args>. Intel brew at /usr/local is left untouched.
  3. Notice — a dismissible Dashboard card (mirrors the existing Exposure card style in both shells) telling the user they're under Rosetta 2 and pointing at the Apple Silicon build.

Files

  • Tauri/Rust: system/profile.rs (detection), brew/exec.rs (arch -arm64 bridge + brew_command), converted spawn sites in vulns/client.rs, commands/brewfile.rs; commands/env.rs exposes rosettaTranslated.
  • Web: types.ts, stores/env.svelte.ts, Dashboard.svelte (notice card).
  • Native: SystemProfile.swift, BrewService.swift (brewInvocation), AppModel.swift, DashboardView.swift (RosettaCard), RosettaDetectionTests.swift.

Tests

  • Rust: translated_only_when_sysctl_reads_one, arm64_reexec_only_for_translated_arm_prefix — full suite green.
  • Native: RosettaDetectionTests (sysctl mapping + brewInvocation gating) — green.
  • svelte-check clean, vitest green.
  • Empirically verified arch -arm64 /opt/homebrew/bin/brew --version succeeds and the card renders under BREWBROWSER_FAKE_ROSETTA=1.

Closes #158

🤖 Generated with Claude Code

msitarzewski and others added 2 commits August 10, 2026 15:32
…notice card (#158)

An Intel build run under Rosetta 2 on Apple Silicon fails every brew
operation with "Cannot install under Rosetta 2 in ARM default prefix" —
a translated (x86_64) process spawning arm-native brew (/opt/homebrew)
is rejected. Terminal works because that brew runs natively. Apple retires
Rosetta 2 in a future macOS release, so the durable fix is the native build.

Both shells:
- Detect translation via sysctl.proc_translated (cached; a runtime check,
  since the compile-time arch check can't see translation). A
  BREWBROWSER_FAKE_ROSETTA override mirrors BREWBROWSER_FAKE_RAM_GB so the
  path is exercisable on native-arm hardware.
- Route every brew spawn through `arch -arm64 <brew>` when translated AND the
  prefix is /opt/homebrew (Intel brew at /usr/local is left alone), so
  operations keep working. Centralized in one helper per shell (also closes a
  gap where `brew bundle check` skipped the analytics-off env).
- Surface a Rosetta 2 notice as a Dashboard card, in the app's existing card
  language (mirrors the Exposure card), steering to the Apple Silicon build.

Tauri: SystemStatus.rosettaTranslated; exec.rs brew_command(); Dashboard.svelte
card. Native: SystemProfile.isTranslated(); BrewService.brewInvocation();
DashboardView RosettaCard.

Tests: Rust profile parse + exec arch-gating; native RosettaDetection. The
`arch -arm64` bridge was verified against real brew, and the card renders with
the window resizing freely.

Closes #158.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X9iMFjHE21ePTjcbHpTXt6
In-flight entry for fix/rosetta2-arch-detection: detection via
sysctl.proc_translated, the arch -arm64 brew bridge, the Dashboard notice
card, and the SwiftUI window-sizing lesson from the abandoned banner attempt.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X9iMFjHE21ePTjcbHpTXt6
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.

"Error: Cannot install under Rosetta 2 in ARM default prefix" on MacOS 15.7.7

1 participant