install: add workaround for rosetta2 path error msg

It's possible the user's terminal emulator is running under rosetta2.
Consequently, the i86_64 version of the ruby interpreter will be used.
Likely, the right thing to do is simply install the arm64 version of the
requested package. This can be accomplished using: arch -arm64 brew ...

Fixes: #10313
This commit is contained in:
David Cowden 2021-01-13 21:16:36 -07:00
parent 663b972f44
commit 9b4fea602b

View File

@ -32,12 +32,16 @@ module Homebrew
def check_prefix
if (Hardware::CPU.intel? || Hardware::CPU.in_rosetta2?) &&
HOMEBREW_PREFIX.to_s == HOMEBREW_MACOS_ARM_DEFAULT_PREFIX
configuration = if Hardware::CPU.in_rosetta2?
"under Rosetta 2"
if Hardware::CPU.in_rosetta2?
configuration = "under Rosetta 2"
odie <<~EOS
Cannot install in Homebrew #{configuration} in ARM default prefix (#{HOMEBREW_PREFIX})!
Try `arch -arm64 brew install ...`
EOS
else
"on Intel processor"
configuration = "on Intel processor"
odie "Cannot install in Homebrew #{configuration} in ARM default prefix (#{HOMEBREW_PREFIX})!"
end
odie "Cannot install in Homebrew #{configuration} in ARM default prefix (#{HOMEBREW_PREFIX})!"
elsif Hardware::CPU.arm? && HOMEBREW_PREFIX.to_s == HOMEBREW_DEFAULT_PREFIX
odie <<~EOS
Cannot install in Homebrew on ARM processor in Intel default prefix (#{HOMEBREW_PREFIX})!