Skip to content

Instantly share code, notes, and snippets.

@pdarragh
Created December 4, 2022 22:32
Show Gist options
  • Save pdarragh/9f615bae6d7a8ffffffa7b733d0a80b0 to your computer and use it in GitHub Desktop.
Save pdarragh/9f615bae6d7a8ffffffa7b733d0a80b0 to your computer and use it in GitHub Desktop.

Revisions

  1. pdarragh created this gist Dec 4, 2022.
    51 changes: 51 additions & 0 deletions x86_racket_on_apple_silicon.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    Finally got around to setting up an x86 instance of Homebrew via Rosetta to install x86 Racket. Here's all the steps I took.

    First, ensure Rosetta 2 is installed:

    ```
    $ /usr/sbin/softwareupdate --install-rosetta
    ```

    Then install x86-64 Homebrew. However, I've also kept the regular Apple Silicon Homebrew. Turns out they require different path prefixes anyway, so the regular one is at `/opt/homebrew` while the x86 one is at `/usr/loca/homebrew`. To install the x86 one, I did:

    ```
    $ mkdir /tmp/homebrew
    $ curl -L https://github.com/Homebrew/brew/tarball/master | tar xz -C /tmp/homebrew --strip-components=1 --
    $ sudo mv /tmp/homebrew /usr/local/
    ```

    I then updated my `$PATH` definitions so that the x86 version's `bin` directory has lower precedence than the Apple Silicon version's, and also created an alias so that I can still easily access the `brew` binary via `brew64` (this is in my `~/.zprofile`):

    ```zsh
    # If the x86-64 Homebrew path is found, include it first.

    [[ ! -d /usr/local/homebrew ]] || {
    alias brew64="arch -x86_64 /usr/local/homebrew/bin/brew"
    export PATH="/usr/local/homebrew/bin:$PATH"
    }

    [[ ! -d /opt/homebrew ]] || export PATH="/opt/homebrew/bin:$PATH"
    ```

    Now I can open a new (regular) terminal, and from the shell I can do `type -a brew64` to see:

    ```
    $ type -a brew64
    brew64 is an alias for arch -x86_64 /usr/local/homebrew/bin/brew
    ```

    With this, I can install `nasm` and Racket:

    ```
    $ brew64 install nasm
    $ brew64 install --cask racket
    ```

    And I can confirm the x86 versions were installed:

    ```
    $ file /usr/local/homebrew/bin/nasm
    /usr/local/homebrew/bin/nasm: Mach-O 64-bit executable x86_64
    $ file /usr/local/homebrew/bin/racket
    /usr/local/homebrew/bin/racket: Mach-O 64-bit executable x86_64
    ```