Skip to content

Instantly share code, notes, and snippets.

@kirkgo
Forked from Neutrollized/rbenv_macos_bigsur.md
Created May 11, 2021 11:27
Show Gist options
  • Save kirkgo/ccff9716990ec52ffdb0919003c946ea to your computer and use it in GitHub Desktop.
Save kirkgo/ccff9716990ec52ffdb0919003c946ea 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 CFLAGS="-Wno-error=implicit-function-declaration"
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl) --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 :)

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