Category filter
Script to install Rosetta 2 on Mac devices with Apple silicon
Apple’s transition from Intel-based processors to Apple silicon brought about many changes to the Mac environment. One of them was that the apps designed and developed for Intel-based processors would no longer run on the Macs with Apple silicon chips. Rosetta 2 is a translation process introduced by Apple to ease this transition, enabling Intel-based software applications to run on Mac computers with Apple silicon.
Rosetta does not come pre-installed on Macs with Apple silicon. However, the system will prompt the user to install Rosetta whenever the user opens an Intel-based installer package. Using Hexnode’s Execute Custom Script action, you can remotely deploy the custom script provided below to install Rosetta 2 across your macOS endpoints.
Install Rosetta on Apple silicon Mac
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# Determine the architecture of the macOS device processorBrand=$(/usr/sbin/sysctl -n machdep.cpu.brand_string) if [[ "${processorBrand}" = *"Apple"* ]]; then echo "Apple Processor is present." else echo "Apple Processor is not present. Rosetta not required." exit 0 fi # Check if Rosetta is installed checkRosettaStatus=$(/bin/launchctl list | /usr/bin/grep "com.apple.oahd-root-helper") RosettaFolder="/Library/Apple/usr/share/rosetta" if [[ -e "${RosettaFolder}" && "${checkRosettaStatus}" != "" ]]; then echo "Rosetta Folder exists and Rosetta Service is running. Exiting..." exit 0 else echo "Rosetta Folder does not exist or Rosetta service is not running. Installing Rosetta..." fi # Install Rosetta /usr/sbin/softwareupdate --install-rosetta --agree-to-license # Check the result of Rosetta install command if [[ $? -eq 0 ]]; then echo "Rosetta installed successfully." exit 0 else echo "Rosetta installation failed." exit 1 fi exit 0 |
The above script will execute the following in order:
- Check the architecture of the macOS Device.
- If the Mac runs on Apple silicon, the script checks if Rosetta is installed.
- If Rosetta is not installed, it is installed silently.
Suppose a binary executable for an application contains instructions for both Intel-based processors (x86_64 instructions) and Apple silicon (arm64 instructions). In that case, the system will prefer to execute the app’s arm64 instructions on Apple silicon Macs. However, the user can configure the app to launch using Rosetta translation by checking the ‘Open using Rosetta’ option in the app’s Get Info window so that the app can run older plug-ins that don’t yet support the arm64 architecture.