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.
This commit is contained in:
Carlo Cabrera 2022-02-04 09:50:21 +08:00
parent 8e97f60858
commit 902b4e1f3f
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0

View File

@ -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.