Skip to content

Instantly share code, notes, and snippets.

@Neutrollized
Last active August 18, 2023 12:35
Show Gist options
  • Save Neutrollized/37841827940b28b27ec2e54abbbcc408 to your computer and use it in GitHub Desktop.
Save Neutrollized/37841827940b28b27ec2e54abbbcc408 to your computer and use it in GitHub Desktop.
Installing Ruby with rbenv on MacOS Big Sur

Errors/Problems with Install

In attempting to install Ruby with rbenv, I ran into the following build failures:

BUILD FAILED (macOS 11.2.3 using ruby-build 20210423)

Inspect or clean up the working tree at /var/folders/58/16lnyx815c183j6wzcbl_thc0000gn/T/ruby-build.20210426232453.81982.XfAg0C
Results logged to /var/folders/58/16lnyx815c183j6wzcbl_thc0000gn/T/ruby-build.20210426232453.81982.log

Last 10 log lines:
                                          ^
In file included from vm.c:350:
./vm_method.c:124:5: warning: function 'rb_f_notimplement' declared 'noreturn' should not return [-Winvalid-noreturn]
    UNREACHABLE_RETURN(Qnil);
    ^
./include/ruby/ruby.h:59:35: note: expanded from macro 'UNREACHABLE_RETURN'
#  define UNREACHABLE_RETURN(val) return (val)
                                  ^
1 warning and 1 error generated.
make: *** [vm.o] Error 1

Resolution

/usr/sbin/pkgutil --packages | grep CL didn't return anything initally, which mean that I had an old version of CommandLineTools and there's no way to update them per se, so I just had to remove and install fresh:

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

/usr/sbin/pkgutil --packages | grep CL now returns:

com.apple.pkg.CLTools_Executables
com.apple.pkg.CLTools_SDK_macOS110
com.apple.pkg.CLTools_SDK_macOS1015
com.apple.pkg.CLTools_macOS_SDK

Final Build Settings

brew install rbenv ruby-build openssl readline libyaml zlib

I ended up adding this to my ~/.zshrc:

# rbenv
export RUBY_CFLAGS="-Wno-error=implicit-function-declaration"
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix [email protected]) --with-readline-dir=$(brew --prefix readline) --with-libyaml-dir=$(brew --prefix libyaml) --with-zlib-dir=$(brew --prefix zlib)"

# Load rbenv
eval "$(rbenv init -)"

rbenv install 2.7.3 (or whatever version you fancy) should work now :)

@Neutrollized
Copy link
Author

Nice! So the openssl version made difference there? Thanks for letting me know!

@dlebedynskyi
Copy link

had similar issues as above. This is recipe that helped me

  1. follow resolution from above to install xcode tools
  2. make sure to have readline from brew brew install rbenv ruby-build openssl
  3. RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix [email protected])" RUBY_CFLAGS="-w" rbenv install 2.7.5 finally passed

@mybedhome
Copy link

had similar issues as above. This is recipe that helped me

  1. follow resolution from above to install xcode tools
  2. make sure to have readline from brew brew install rbenv ruby-build openssl
  3. RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix [email protected])" RUBY_CFLAGS="-w" rbenv install 2.7.5 finally passed

Nice! It's work for me

@mohsintahir
Copy link

had similar issues as above. This is recipe that helped me

  1. follow resolution from above to install xcode tools
  2. make sure to have readline from brew brew install rbenv ruby-build openssl
  3. RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix [email protected])" RUBY_CFLAGS="-w" rbenv install 2.7.5 finally passed

It worked for me while installing Ruby 2.5.8 on MacOS 13.

@bryanltobing
Copy link

RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix [email protected])" RUBY_CFLAGS="-w" rbenv install 2.7.5

this worked for me on mac m1

@OkungbowaGodspower
Copy link

It worked for me on MacBook Air

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