Skip to content

Instantly share code, notes, and snippets.

@MarkBennett
Last active March 23, 2024 10:21
Show Gist options
  • Star 36 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save MarkBennett/b123f72c5d15703f7cceb75b6a0e365a to your computer and use it in GitHub Desktop.
Save MarkBennett/b123f72c5d15703f7cceb75b6a0e365a to your computer and use it in GitHub Desktop.
Installing Ruby 2.5 on Mac M1

I was able to get Ruby 2.5.1 building on M1 by following two of the steps in that GH issue...

rbenv/ruby-build#1691 (comment) rbenv/ruby-build#1691 (comment)

I installed readline and openssl with standard brew install.

brew install readline
brew install openssl

Then I set this in my ~/.zshrc..

# Homebrew
export PATH=/opt/homebrew/bin:$PATH
export PATH="/opt/homebrew/sbin:$PATH"
# rbenv
export RBENV_ROOT=/opt/homebrew/opt/rbenv
export PATH=$RBENV_ROOT/bin:$PATH
eval "$(rbenv init -)"
# openssl
export PATH="/opt/homebrew/opt/openssl@1.1/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@1.1/lib/pkgconfig"
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=/opt/homebrew/opt/openssl@1.1"

Then I ran this command:

RUBY_CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.5

I haven't been able to test this yet, but @samik3k has reported that this no longer works, but that the following command does.

RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC rbenv install 2.5.8

Please reply and let me know if this works for you and I'll update the steps above as I don't have Ruby setup on my M1 Mac right now.

@neymarsabin
Copy link

neymarsabin commented Jun 11, 2023

thanks @Tokiyomi, this command worked for me for m1 mac.
RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC rbenv install 2.5.0

@thadeu
Copy link

thadeu commented Aug 29, 2023

Just this command worked for me:

RUBY_CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.5.5

It's works for me

@rsimenok
Copy link

oh, thank you a lot!

@moz3
Copy link

moz3 commented Nov 8, 2023

RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC rbenv install 2.5.9
working on MacOS 14 and M2 processor. thank you! <3

@mmusgrave
Copy link

mmusgrave commented Nov 28, 2023

ruby-install 2.5.8 -- CFLAGS="-DUSE_FFI_CLOSURE_ALLOC" worked on MacOS 14.1 Sonoma and M3. Thank you!

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