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
/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
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 openssl@1.1) --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 :)
Thanks for this! I didn't have any CLTools installed, and had a different build error, but I just ran
export CFLAGS="-Wno-error=implicit-function-declaration"
in my shell and I was immediately able torbenv install 2.6.7
=)