How To Install Homebrew, Ruby, Rails, Jekyll On A Mac With The M1 (Apple Silicon) Chip

Instead of boring you with the background history that I was starting to write, I realized it can all be summarized to these 3 points:

Homebrew installs things in a different directory when in native mode (/opt/homebrew) versus /usr/local in Rosetta mode (or when using the arch -x86_64 flag). So, it’s easy to get confused and run into issues if you launched Terminal in native mode but started running some commands with arch -x86_64 and others without. Or if you launched Terminal in Rosetta mode and then tried to work with things that expected native mode.

When you use my script, you don’t have to worry about any of this.

Although it can detect which mode you’re in and install Homebrew and other tools in the appropriate places, I recommend doing everything in native mode since it’s fully supported now. I’ve been using Jekyll and Rails without any issues on my M1 MacBook Air. My script also automatically installs Jekyll and Rails for you.

One issue you might run into if you have an existing Ruby project with an older version of the ffi gem, is an error saying failed to load command and then a more specific error like this one:

~/.gem/ruby/2.7.2/gems/ffi-1.13.1/lib/ffi/types.rb:69:in `find_type': 
unable to resolve type 'size_t' (TypeError)

The solution is simple:

bundle update ffi

For Rails and Jekyll projects, you might need to update both ffi and sassc:

bundle update ffi sassc

If you see other unexpected errors that point to a particular gem, the first thing I would try is to update that gem.

How to tell if you are using Terminal in Rosetta mode

Launch Terminal, or whatever app you’re using to interact with the command line, then run this command:

uname -m

If it says x86_64, you are using Rosetta. If it says arm64, you are good to go.

How to turn off Rosetta mode

  1. Quit Terminal and any other app that uses the terminal (such as iTerm, VS Code, Sublime Text).
  2. Open a new Finder window.
  3. Go to Applications -> Utilities.
  4. Click once on the Terminal app to select it.
  5. Press the command-i keyboard shortcut to open the Info window.
  6. Make sure the “Open using Rosetta” checkbox is unchecked.
  7. Close the info window
  8. Launch Terminal
  9. Verify that uname -m shows arm64