Skip to content

Instantly share code, notes, and snippets.

@MarkBennett
Last active January 2, 2025 09:19
Show Gist options
  • 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/[email protected]/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib"
export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/[email protected]/lib/pkgconfig"
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=/opt/homebrew/opt/[email protected]"

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.

@IMDaniyal
Copy link

RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC rbenv install 2.5.0

This worked on MacOS 14.2 M2. Thank you!

@vizcay
Copy link

vizcay commented Jun 30, 2024

Got 2.4.9 working on a M1 with
RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC rbenv install 2.4.9

@mklemersson
Copy link

Got the version 2.5.1 working on a Mac M3

RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC rbenv install 2.5.1

@lcmen
Copy link

lcmen commented Oct 24, 2024

For me, a following command worked:

RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC RUBY_CONFIGURE_OPTS="--with-openssl-dir=/opt/homebrew/opt/[email protected]" asdf install ruby 2.5.1

@sbpipb
Copy link

sbpipb commented Jan 2, 2025

For me, a following command worked:

RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC RUBY_CONFIGURE_OPTS="--with-openssl-dir=/opt/homebrew/opt/[email protected]" asdf install ruby 2.5.1

tried but failed on macbook m2, sequoia

-> ./configure "--prefix=$HOME/.asdf/installs/ruby/2.5.3" --enable-shared --with-readline-dir=/opt/homebrew/opt/readline --with-libyaml-dir=/opt/homebrew/opt/libyaml --with-gmp-dir=/opt/homebrew/opt/gmp --with-ext=openssl,psych,+ --with-openssl-dir=/opt/homebrew/opt/[email protected]
-> make -j 8

BUILD FAILED (macOS 15.1.1 on arm64 using ruby-build 20241105)

@sbpipb
Copy link

sbpipb commented Jan 2, 2025

Got the version 2.5.1 working on a Mac M3

RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC rbenv install 2.5.1

this worked like a charm! thank you!

ruby-build: using readline from homebrew
ruby-build: using libyaml from homebrew
ruby-build: using gmp from homebrew
-> ./configure "--prefix=$HOME/.rbenv/versions/2.5.3" "--with-openssl-dir=$HOME/.rbenv/versions/2.5.3/openssl" --enable-shared --with-readline-dir=/opt/homebrew/opt/readline --with-libyaml-dir=/opt/homebrew/opt/libyaml --with-gmp-dir=/opt/homebrew/opt/gmp --with-ext=openssl,psych,+
-> make -j 8
-> make install
==> Installed ruby-2.5.3 to /Users/julianaustin/.rbenv/versions/2.5.3

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