From 9b4fea602b474100a5fd8ac8a9f059db8bcddd59 Mon Sep 17 00:00:00 2001 From: David Cowden Date: Wed, 13 Jan 2021 21:16:36 -0700 Subject: [PATCH 1/4] 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 --- Library/Homebrew/install.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/install.rb b/Library/Homebrew/install.rb index 9b4ece01eb..a29b4803cd 100644 --- a/Library/Homebrew/install.rb +++ b/Library/Homebrew/install.rb @@ -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})! From 0562d0c2b6294df55c3b16b74e2b13172c9e58d8 Mon Sep 17 00:00:00 2001 From: David Cowden Date: Thu, 14 Jan 2021 14:26:41 -0700 Subject: [PATCH 2/4] fixup: reword error message and remove pointless variable --- Library/Homebrew/install.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/install.rb b/Library/Homebrew/install.rb index a29b4803cd..1979eaefd8 100644 --- a/Library/Homebrew/install.rb +++ b/Library/Homebrew/install.rb @@ -33,14 +33,19 @@ module Homebrew if (Hardware::CPU.intel? || Hardware::CPU.in_rosetta2?) && HOMEBREW_PREFIX.to_s == HOMEBREW_MACOS_ARM_DEFAULT_PREFIX 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 ...` + This invocation of Homebrew is being translated by Rosetta2 however it is + installed in the ARM default prefix (#{HOMEBREW_PREFIX})! Are you are using an + x86_64 build of your terminal emulator? All invocations of this Homebrew + installation must be native arm64. + Use: + arch -arm64 brew install ... + + to invoke Homebrew natively. Alternatively, if indeed you want x86_64 packages, + setup a separate x86_64 Homebrew installation and invoke that one. EOS else - configuration = "on Intel processor" - odie "Cannot install in Homebrew #{configuration} in ARM default prefix (#{HOMEBREW_PREFIX})!" + odie "Cannot install on Intel processor in ARM default prefix (#{HOMEBREW_PREFIX})!" end elsif Hardware::CPU.arm? && HOMEBREW_PREFIX.to_s == HOMEBREW_DEFAULT_PREFIX odie <<~EOS From db52d6a72563e3ad55356a0db9e17d617ed206d4 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 25 Jan 2021 10:39:29 -0700 Subject: [PATCH 3/4] Update Library/Homebrew/install.rb Incorporate suggested wording Co-authored-by: Mike McQuaid --- Library/Homebrew/install.rb | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Library/Homebrew/install.rb b/Library/Homebrew/install.rb index 1979eaefd8..ad887d8f1e 100644 --- a/Library/Homebrew/install.rb +++ b/Library/Homebrew/install.rb @@ -34,15 +34,10 @@ module Homebrew HOMEBREW_PREFIX.to_s == HOMEBREW_MACOS_ARM_DEFAULT_PREFIX if Hardware::CPU.in_rosetta2? odie <<~EOS - This invocation of Homebrew is being translated by Rosetta2 however it is - installed in the ARM default prefix (#{HOMEBREW_PREFIX})! Are you are using an - x86_64 build of your terminal emulator? All invocations of this Homebrew - installation must be native arm64. - Use: + Cannot install under Rosetta 2 in ARM default prefix (#{HOMEBREW_PREFIX})! + To rerun under ARM use: arch -arm64 brew install ... - - to invoke Homebrew natively. Alternatively, if indeed you want x86_64 packages, - setup a separate x86_64 Homebrew installation and invoke that one. + To install under x86_64, install Homebrew into #{HOMEBREW_DEFAULT_PREFIX}. EOS else odie "Cannot install on Intel processor in ARM default prefix (#{HOMEBREW_PREFIX})!" From 786a06d3ed7385bf56d48185c5b5d075aba36d21 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 26 Jan 2021 10:21:55 +0000 Subject: [PATCH 4/4] Library/Homebrew/install: fix whitespace. --- Library/Homebrew/install.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/install.rb b/Library/Homebrew/install.rb index ad887d8f1e..a59dc55a9d 100644 --- a/Library/Homebrew/install.rb +++ b/Library/Homebrew/install.rb @@ -35,7 +35,7 @@ module Homebrew if Hardware::CPU.in_rosetta2? odie <<~EOS Cannot install under Rosetta 2 in ARM default prefix (#{HOMEBREW_PREFIX})! - To rerun under ARM use: + To rerun under ARM use: arch -arm64 brew install ... To install under x86_64, install Homebrew into #{HOMEBREW_DEFAULT_PREFIX}. EOS