fix(rosetta2): detect Rosetta 2, route brew through arch -arm64, add notice card - #169
Open
msitarzewski wants to merge 2 commits into
Open
fix(rosetta2): detect Rosetta 2, route brew through arch -arm64, add notice card#169msitarzewski wants to merge 2 commits into
msitarzewski wants to merge 2 commits into
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Fixes #158 —
Error: Cannot install under Rosetta 2 in ARM default prefixon Apple Silicon. A translated (x86_64) build of the app spawning arm-nativebrewat/opt/homebrewis 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).is_translated()/SystemProfile.isTranslated(), cached; honorsBREWBROWSER_FAKE_ROSETTA=1for QA./opt/homebrew, spawn brew via/usr/bin/arch -arm64 <brew> <args>. Intel brew at/usr/localis left untouched.Files
system/profile.rs(detection),brew/exec.rs(arch -arm64bridge +brew_command), converted spawn sites invulns/client.rs,commands/brewfile.rs;commands/env.rsexposesrosettaTranslated.types.ts,stores/env.svelte.ts,Dashboard.svelte(notice card).SystemProfile.swift,BrewService.swift(brewInvocation),AppModel.swift,DashboardView.swift(RosettaCard),RosettaDetectionTests.swift.Tests
translated_only_when_sysctl_reads_one,arm64_reexec_only_for_translated_arm_prefix— full suite green.RosettaDetectionTests(sysctl mapping +brewInvocationgating) — green.arch -arm64 /opt/homebrew/bin/brew --versionsucceeds and the card renders underBREWBROWSER_FAKE_ROSETTA=1.Closes #158
🤖 Generated with Claude Code