From 902b4e1f3f493dad186724da782384124bcd3d6b Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Fri, 4 Feb 2022 09:50:21 +0800 Subject: [PATCH] cask/dsl/caveats: add `:requires_rosetta` Some casks will fail to install with a `Bad CPU type in executable` error on Apple Silicon. See Homebrew/homebrew-cask#118638. This error can be quite confusing, so let's add a way to help users know that they need to install Rosetta to use or even install a cask. --- Library/Homebrew/cask/dsl/caveats.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Library/Homebrew/cask/dsl/caveats.rb b/Library/Homebrew/cask/dsl/caveats.rb index 7a0591c76d..0436481f09 100644 --- a/Library/Homebrew/cask/dsl/caveats.rb +++ b/Library/Homebrew/cask/dsl/caveats.rb @@ -127,6 +127,17 @@ module Cask end end + caveat :requires_rosetta do + next unless Hardware::CPU.arm? + + <<~EOS + #{@cask} is built for Intel macOS and so requires Rosetta 2 to be installed. + You can install Rosetta 2 with: + softwareupdate --install-rosetta --agree-to-license + Note that it is very difficult to remove Rosetta 2 once it is installed. + EOS + end + caveat :logout do <<~EOS You must log out and log back in for the installation of #{@cask} to take effect.