Skip to content

Instantly share code, notes, and snippets.

@davidteren
Created August 31, 2022 07:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save davidteren/3a5ddb489fcbe613adc06e3c4fdb010f to your computer and use it in GitHub Desktop.
Save davidteren/3a5ddb489fcbe613adc06e3c4fdb010f to your computer and use it in GitHub Desktop.
Run Ruby via asdf on M1 Macs

Remove Rbenv

brew remove rbenv
rm -rf ~/.rbenv

Remove the following line from your .zshrc

eval "$(rbenv init - zsh)"

Re-install xcode commandline tools

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

Re-install build dependancies

brew uninstall --ignore-dependencies readline
brew uninstall --ignore-dependencies openssl
brew uninstall --ignore-dependencies ruby-build
rm -rf /opt/homebrew/etc/openssl@1.1
brew install -s readline
brew install -s openssl
brew install -s ruby-build
brew reinstall openssl@1.1

Add the following to your .zshrc

export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)"
export LDFLAGS="-L/opt/homebrew/opt/readline/lib:$LDFLAGS"
export CPPFLAGS="-I/opt/homebrew/opt/readline/include:$CPPFLAGS"
export PKG_CONFIG_PATH="/opt/homebrew/opt/readline/lib/pkgconfig:$PKG_CONFIG_PATH"
export optflags="-Wno-error=implicit-function-declaration"
export LDFLAGS="-L/opt/homebrew/opt/libffi/lib:$LDFLAGS"
export CPPFLAGS="-I/opt/homebrew/opt/libffi/include:$CPPFLAGS"
export PKG_CONFIG_PATH="/opt/homebrew/opt/libffi/lib/pkgconfig:$PKG_CONFIG_PATH"

Install asfd

brew install asdf

Add the following line to your ~/.zshrc:

. /opt/homebrew/opt/asdf/libexec/asdf.sh

Close and reopen you terminal

Add the asdf Ruby plugin

asdf plugin add ruby     

Install a Ruby version

asdf install ruby 2.6.6

Set the version for local use

asdf local ruby 2.6.6

Note: this will create a .tools-version file that asdf uses to determine versions.

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