Ruby Installation (2.2.2) Fails in MACos Big Sur

Ruby installation (2.2.2) fails in macOS Big Sur

EDIT

It looks like OP edited the error in the original message so the below answer is no longer relevant. Leaving it here for posterity.



Updated Answer

Based on discussion in a couple of Github issues on the rbenv repo,

  • https://github.com/rbenv/ruby-build/issues/1480
  • https://github.com/rbenv/ruby-build/issues/1489

it sounds like Apple changed the default CFLAGS as part of xcode 12, which makes some of the native extension installations go haywire. It sounds like the solution proposed in those issues is

CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.2.2


Original answer

The error states it failed due to issues with extensions

The Ruby readline extension was not compiled.
The Ruby zlib extension was not compiled.
ERROR: Ruby install aborted due to missing extensions

so I would suggest trying to install those extensions manually first, then retrying the ruby install.

With brew:

brew install readline
brew install zlib

There are some issues on ruby-build's github that might help as well:

  • https://github.com/rbenv/ruby-build/issues/1076
  • https://github.com/rbenv/ruby-build/issues/832#issuecomment-160906530

Ruby: BUILD FAILED (macOS 11.2 using ruby-build 20210119) Mac Big Sur

This is not an official solution. I'm sure the rbenv devs are working on an actual solution but this workaround should help others who are setting up their ruby environments on the new M1 chips for Mac.

  • Make sure your Terminal is using Rosetta. You can find how to do that using Google.

  • Uninstall your current rbenv following these instructions Removing rbenv. Be sure you also remove all the downloaded versions of ruby if you have any (minus the system default) located in /Users/<your user name>/.rbenv/versions/.

  • Uninstall the ARM version of Homebrew with: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"

  • Install the x86_64 version of Homebrew with: arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

  • If you run brew install rbenv should produce output saying "Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!". This is expected.

  • You want to tell brew to install the older architecture x86_64 arch -x86_64 brew install rbenv

  • Then finally install the version you want using arch -x86_64 rbenv install x.x.x (x = some number i.e. 2.7.2)

From there you just need to remember to tell brew arch -x86_64 when installing other versions of Ruby.

Once an actual fix comes through you'll be able to switch back to the newer architecture and not have to use the arch argument. You also don't have to do this all the time with brew either, just rbenv.

Ruby 2.7.4 & 3.0.0 fails on macOS Big Sur (11.2.3): undeclared identifier RSA_SSLV23_PADDING

ruby-install takes care of installing the OpenSSL dependency for you, but there was a bug in ruby-install where it wasn't specifying the exact openssl version that needed to be installed. Thankfully that's been fixed:

  1. Upgrade ruby-install to >=0.8.3 (e.g., brew upgrade ruby-install) which pins the openssl dependency for ruby at 1.1
  2. Install ruby 3 (e.g., ruby-install ruby 3.0.2)

Details:

This was solved in ruby-install (first reported with https://github.com/postmodern/ruby-install/issues/409). Homebrew defaulted openssl to 3.0 (the latest major version) but Ruby hasn't yet added support for OpenSSL3.0. As such openssl dependency ruby-install was attempting to use was the wrong version (Ruby is still on 1.1).

Installing ruby-2.1.2: Cannot load such file -- openssl (LoadError)

Ruby <2.4 is incompatible with OpenSSL 1.1 (e.g see https://github.com/rbenv/ruby-build/issues/1353).

Just a hunch, but if you're using Mac + Homebrew, OpenSSL 1.0 was recently deleted, so anything along the lines of brew upgrade openssl would trash that.

There are several options to deal with this:

  1. I have older Rubies via asdf installed with LibreSSL (which may be safer anyway, see https://security.stackexchange.com/questions/112545/what-are-the-main-advantages-of-using-libressl-in-favor-of-openssl):
$ openssl
OpenSSL> version
LibreSSL 2.8.3

  1. Compile and link your own OpenSSL 1.0 (or then set compiler flags as environment variables when building Ruby -- https://rvm.io/rubies/installing)
  2. See if your system's package manager allows you to access openssl 1.0 and install with that (was helping a coworker with this recently and we weren't able to find a good keg for homebrew at this time, unfortunately)

There might be something less convoluted than that; if someone has ideas, please feel free to comment or give an alternate answer.

EDIT

I personally ran into this issue with some other software and discovered that this fixed it, since the old SSL version was sitting around still:

brew switch openssl 1.0.2s

Should work so long as Homebrew doesn't "helpfully" clean that out for me.

Error installing Ruby 2.3.8 in OSX 10.15.2 Catalina using RVM; OpenSSL not found

I tried everything and came to conclusion that there is problem with the binary of ruby 2.3.8 RVM has. The I removed RVM from my system and start using rbenv.

With Homebrew

$ brew install rbenv
$ rbenv init
# Do as it says
$ rbenv install 2.3.8

also make sure you the use the bundler specified in your legacy code's Gemfile.lock



Related Topics



Leave a reply



Submit