One of the reasons I took the plunge and bought an M1-based Mac is to test out its performance and suitability as a developer. An essential developer application on the Mac is Homebrew, the “missing package manager for macOS.” Although you cannot install Homebrew today to manage ARM-compiled packages, you can install Homebrew in the Rosetta environment and leverage the x86 packages.
I can’t take credit for coming up with the idea, that would go to OSX Daily, but I have a few improvements to share. I’m going to use iTerm2, and so should you.
Right click on your iTerm application icon and select Duplicate. Rename iTerm copy to something like iTerm x86 or iTerm Rosetta.
Now, right click on your new iTerm icon and click on Get Info and then check Open using Rosetta.
Open your iTerm Rosetta application and install Homebrew! Once installed you should be able to use brew install
in the iTerm Rosetta application and use those installed packages seamlessly between the two environments. You won’t, however, be able to use brew install
in your arm64 iTerm application (you’ll get Error: Cannot install in Homebrew on ARM processor in Intel default prefix
).
Keeping Track
If you’re working in both x86 and ARM environments on your M1 Mac it is easy to lose track which iTerm you are in. We can use a little zsh
-foo to help us out. Add the following snippet to the end of your ~/.zshrc
:
1 2 3 4 5 6 |
_ARCH=$(arch) PROMPT="$_ARCH $PROMPT" # Requires iterm2 if [[ "$_ARCH" == "i386" ]]; then echo -ne "\033]1337;SetColors=bg=0071C5\007" fi |
This little snippet takes advantage of iTerm2’s custom escape codes by setting the background to Intel blue if the arch
command returns i386
(which it does if running in Rosetta).
We can do one better, however, by changing our iTerm Rosetta icon. Create your own icon, or, right-click the image below and select Copy Image. Then right-click your iTerm Rosetta application and select Get Info. In the upper-left click on the icon until you see a highlight around it and then paste the new icon image (Command-V).
Launch your iTerm Rosetta application and it’s much easier to distinguish between it and your “native” version.