6

I want to install and run two versions of Homebrew simultaneously on an Apple Silicon Mac: an ARM64 version, and an Intel version running under Rosetta 2.

I know I can prepend any brew command with arch --x86_64 to emulate Intel for that command, but this can lead to conflicts for formulas whose dependencies you already have built for ARM64. For example:

Error: gnupg dependencies not built for the x86_64 CPU architecture:
  pkg-config was built for arm64
  gettext was built for arm64
  readline was built for arm64
  openssl@1.1 was built for arm64

How can I install and run two separate, isolated versions of Homebrew (one for native ARM64 and one for emulated Intel), keeping each of their installed formulae and dependencies separate?

Jacob Ford
  • 2,300
  • 1
  • 18
  • 34

1 Answers1

20
  1. Install Homebrew natively on Apple Silicon in /opt/homebrew:

    mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
    
  2. Install Intel-emulated Homebrew to the default /usr/local:

    arch --x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
    

    If you haven't yet installed Rosetta 2, you'll need to run softwareupdate --install-rosetta first.

  3. Create an alias for Intel homebrew. I'm calling mine brow because O for old. But hey you do your own thing.

    In ~/.zshrc (or your shell's equivalent) add:

    alias brow='arch --x86_64 /usr/local/Homebrew/bin/brew'
    
  4. Add ARM Homebrew to your PATH.

    In ~/.zshrc (or your shell's equivalent) add:

    # Homebrew on Apple Silicon
    path=('/opt/homebrew/bin' $path)
    export PATH
    

    If you're still on bash it'd be PATH=/opt/homebrew/bin:$PATH

  5. Confirm

    which brew should return /opt/homebrew/bin/brew

    brew --prefix should return /opt/homebrew

    which brow should return brow: aliased to arch --x86_64 /usr/local/Homebrew/bin/brew

    brow --prefix should return /usr/local


If you have the same command installed in both Homebrews, it'll default to Apple Silicon (/opt/homebrew/) since we prepended that one in our PATH. To override, run the command with its full path (/usr/local/bin/youtube-dl), or override your PATH for one command (PATH=/usr/local/bin youtube-dl).

I also created another handy alias in .zshrc (alias ib='PATH=/usr/local/bin') so I can prepend any Homebrew-installed command with ib to force using the Intel version of that command:

~ ▶ which youtube-dl
/opt/homebrew/bin/youtube-dl
~ ▶ ib which youtube-dl
/usr/local/bin/youtube-dl

If you prefer Intel to be the default brew, add /opt/homebrew/bin to the end of your PATH instead of the beginning.

Jacob Ford
  • 2,300
  • 1
  • 18
  • 34
  • for some reason the `arch` command does not work for me ... :( ```bash $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" Password: Homebrew is not (yet) supported on ARM processors! [...] ``` i tried about everything i could find, but I start thinking I'm the only one. help? maybe? – flypenguin Dec 10 '20 at 21:49
  • @flypenguin It looks like you're actually not using the `arch` command, which is why Homebrew is refusing to install. Prepend what you pasted above with `arch --x86_64`. – Jacob Ford Jan 04 '21 at 01:53
  • 2
    dude you are a life saver – Vandit Shah Mar 06 '21 at 09:23