Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bin/brew: re-exec self under Rosetta if needed #9287

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions bin/brew
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ then
fi
fi

# If we're in /usr/local, which is the prefix we've set aside for Intel under Rosetta 2,
# and this is an arm64 machine not running under Rosetta, then re-exec this same file
# within Rosetta with all arguments passed to it.
if [[ "$(uname -s)" = "Darwin" ]] && \
[[ "$HOMEBREW_PREFIX" = "/usr/local" ]] && \
[[ "$(sysctl -n hw.optional.arm64 2>/dev/null)" = "1" ]] && \
[[ "$(sysctl -n sysctl.proc_translated 2>/dev/null)" = "0" ]]; then
exec arch -x86_64 "$HOMEBREW_BREW_FILE" "$@"
fi

HOMEBREW_LIBRARY="$HOMEBREW_REPOSITORY/Library"

# Copy and export all HOMEBREW_* variables previously mentioned in
Expand Down