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

Updated

When the first M1 Macs were released in late 2020, Homebrew and other development tools were not quite ready to run in native mode with the Apple Silicon chip ARM architecture. Today, that is no longer an issue for Ruby development.

Unfortunately, you will still find many outdated blog posts and people who still recommend using Rosetta, or running commands with arch -x86_64, or making changes to your shell file to set the architecture.

This is the source of a lot of confusion and headaches.

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.

This can lead to all kinds of issues, such as incompatible architecture and failed to load command errors, such as this one:

bundler: failed to load command: jekyll
incompatible architecture (have x86_64 need arm64e)

Another reason many people run into issues with Ruby on M1 Macs is because they’re trying to use the version of Ruby that came preinstalled on macOS. Learn why you shouldn’t use the system Ruby.

If you’re running into issues installing Ruby or gems like Rails, Jekyll, ffi, sqlite, sassc, and cocoapods, then I recommend trying again in native mode and making sure you’re not using Rosetta.

How to tell if you’re 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’re using Rosetta. If it says arm64, you’re 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. Go to the Finder

  3. Go to the Utilities folder by pressing shift-⌘-U (or select “Go” from the menu bar, then select Utilities)

  4. Click once on the Terminal app to select it, but don’t launch it.

  5. Press the ⌘-i keyboard shortcut to open the Info window (or from the menu bar: “File”, then “Get Info”).

  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

Still having issues after turning off Rosetta?

If you’re running in native mode and still having issues installing Ruby itself, or installing and using Ruby gems, then I recommend trying my Ruby on Mac script. The Prime version has a reset mode that can safely back up and clean up your dev setup in less than 60 seconds, and then install everything you need from scratch in minutes.

I guarantee that the Prime version will fix your Ruby issues, or I will personally set up your Mac for you.

Note that Ruby on Mac will fix your dev setup so that you can install the latest versions of gems. If you’re running into issues while trying to install older versions of gems with bundle install in existing projects, then the first thing I would recommend is to update your gems.

For example, 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