Skip to content

Instantly share code, notes, and snippets.

@otavioschwanck
Last active April 26, 2022 19:44
Show Gist options
  • Save otavioschwanck/b16f7753d5e075eff94300cf37e85292 to your computer and use it in GitHub Desktop.
Save otavioschwanck/b16f7753d5e075eff94300cf37e85292 to your computer and use it in GitHub Desktop.
Rails 7 on m1 mac

Why install in this way?

To fix some problems with the arm version, like puma SSL.

if you problem is only SSL, try it:

Remove gem puma: gem uninstall puma

And run bundle with DISABLE_SSL=1 bundle install

1 - Add to your .zshrc:

alias ibrew='arch -x86_64 /usr/local/bin/brew'
alias abrew='/opt/homebrew/bin/brew'
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

2 - Remove your current ruby version manager (rvm, rbenv, asdf, etc)

3 - Install homebrew on rosetta 2 (Intel emulation)

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

4 - Install dependencies

arch -x86_64 /usr/local/bin/brew install readline openssl zlib pg sqlite rbenv

5 - Install ruby

arch -x86_64 \
  env RUBY_CONFIGURE_OPTS="--with-readline-dir=/usr/local/opt/readline" \
  rbenv install 2.7.1
  
  rbenv global 2.7.1

6 - Fix sqlite

bundle config build.sqlite3 --with-sqlite3-include=$(ibrew --prefix sqlite)/include --with-sqlite3-lib=$(ibrew --prefix sqlite)/lib

7 - Install pg on the right way (Requires Postgresql.app installed)

gem install pg -- \
  --with-pg-lib=/Applications/Postgres.app/Contents/Versions/13/lib \
  --with-pg-include=/Applications/Postgres.app/Contents/Versions/13/include

Obs: You can specifiy the version in your project with -v 1.2.3

8 - Run Bundle Install on your project (or use rails new with DISABLE_SSL=1)

DISABLE_SSL=1 bundle install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment