Skip to content

Instantly share code, notes, and snippets.

@iscott
Last active August 23, 2023 14:06
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save iscott/e074ae8865594615ff4000c337e2bca1 to your computer and use it in GitHub Desktop.
Save iscott/e074ae8865594615ff4000c337e2bca1 to your computer and use it in GitHub Desktop.
How to get rails to work on an M1 Mac

UPDATE IN PROGRESS:

Experimenting with this instead:

  • rbenv versions
  • rbenv uninstall x.y.z # uninstall all versions from the last step
  • brew uninstall rbenv
  • uninstalling homebrew
  • removing postgres.app
  • reinstall homebrew - not in rosetta 2
  • brew install postegresql
  • Then install rbenv and the latest ruby version
  • brew services start postgresql

Original:

Uninstall the m1 version of rbenv:

brew uninstall rbenv

Completely uninstall homebrew:

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

Re-install homebrew using the x86 architecture version because apparently the pg gem will only compile with this version, which means rosetta2 has to be enabled

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

Then we installthe x86 version of rbenv

arch -x86_64 brew install rbenv

Then configure it to use ruby version 3.0.0 (that’s what version my M1 Mac is using) - FYI this only worked as sudo

sudo arch -x86_64 rbenv install 3.0.0

Give access to the ~/.rbenv folder so you don't have to use sudo:

chmod -R 777 ~/.rbenv

Then we configure rbenv for that version

rbenv global 3.0.0
sudo rbenv rehash

Then we install rails

gem install rails --pre
sudo rbenv rehash
@sekmo
Copy link

sekmo commented Feb 8, 2023

is this still valid? do we need all of this currently?

@jongwonIee
Copy link

jongwonIee commented Apr 19, 2023

Thank you.
This worked for me.
I also used this on top.

@sekmo
Copy link

sekmo commented Aug 23, 2023

btw I've starting using asdf as a version manager for ruby, since it also supports node, go, elixir..
https://github.com/asdf-vm/asdf-plugins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment