Skip to content

Instantly share code, notes, and snippets.

@MarkBennett
Last active December 12, 2024 08:44
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.

@ba11b0y
Copy link

ba11b0y commented Feb 4, 2022

Thanks @klaygomes
Works like a charm!

@rubyonrails3
Copy link

@klaygomes awesome it worked!

@frostmark
Copy link

Thank you! It helped to me

@zaheeraws
Copy link

zaheeraws commented May 13, 2022

Just this command worked for me:

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

@whatcould
Copy link

@zaheeraws that worked for me for 2.5.3, thanks! The flags above still gave me an error.

@unixsuperhero
Copy link

worked for 2.5.8, on an m1 max mac studio

@gentax
Copy link

gentax commented Jul 19, 2022

worked for 2.5.3 on my macbook air M1.
Good catch!

@dankild
Copy link

dankild commented Jul 27, 2022

Thank you! Worked well on MBP 14 for Ruby 2.5.8!

@jraczynski
Copy link

Also helped me, thanks! M1, Ruby 2.5.9.

@danielricecodes
Copy link

You should use brew install [email protected] since homebrew now install openssl 3 by default.

@samik3k
Copy link

samik3k commented Nov 26, 2022

Not working anymore, rbent and rvm variant, compilation error. Anyone know how to fix it on macos 13.0.1?

@samik3k
Copy link

samik3k commented Nov 26, 2022

Working RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC rbenv install 2.5.8

@fabianof
Copy link

Working RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC rbenv install 2.5.8

It worked like a charm. Thanks a lot.

@emskaplann
Copy link

Working RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC rbenv install 2.5.8

worked for m2 - thanks a lot!

@ndisampson
Copy link

ndisampson commented Feb 5, 2023

This worked for me for Ruby 2.5.3. Thanks!

RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC rbenv install 2.5.3

@llaryssa
Copy link

llaryssa commented Mar 1, 2023

omg after spending hours on it, this worked for 2.5.1. thank you!!!

btw i used RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC rbenv install 2.5.1

@maryshirl
Copy link

RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC rbenv install 2.5.8

Worked for me.. thank you so much!

@Tokiyomi
Copy link

Tokiyomi commented Mar 21, 2023

RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC rbenv install 2.5.9

Worked for me

@mayankgupta-hownow
Copy link

Working RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC rbenv install 2.5.8

I am getting this error

BUILD FAILED (macOS 12.5 using ruby-build 20230428)

Inspect or clean up the working tree at /var/folders/9v/fyfzm2g90r59t0t1d3jntr7h0000gn/T/ruby-build.20230509151414.51293.ayBIaQ
Results logged to /var/folders/9v/fyfzm2g90r59t0t1d3jntr7h0000gn/T/ruby-build.20230509151414.51293.log

@enumera
Copy link

enumera commented May 10, 2023

Working RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC rbenv install 2.5.8

Now getting this:
BUILD FAILED (macOS 13.3.1 using ruby-build 20230428)

Inspect or clean up the working tree at /var/folders/cm/mkx4qhrs1d38wtm9sdlyh_tc0000gn/T/ruby-build.20230510233814.24844.UGhjv0

I am now sure how to go about clearing this?

@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!

@tushar7k9
Copy link

Just this command worked for me:

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

Thanks @zaheeraws that worked for me!

@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

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