Ruby installation (2.2.2) fails in macOS Big Sur
Asked Answered
H

1

6

I am running into some trouble installing Ruby 2.2.2 on macOS Big Sur. Has anyone had a similar issue that they were able to resolve? Many thanks πŸ™

Error:

`Downloading openssl-1.0.2u.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/ecd0c6ffb493dd06707d38b14bb4d8c2288bb7033735606569d8f90f89669d16
Installing openssl-1.0.2u...
Installed openssl-1.0.2u to /Users/findum/.rbenv/versions/2.2.2

Downloading ruby-2.2.2.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.2.tar.bz2
Installing ruby-2.2.2...

WARNING: ruby-2.2.2 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.

ruby-build: using readline from homebrew

BUILD FAILED (macOS 11.1 using ruby-build 20201225)

Inspect or clean up the working tree at /var/folders/x8/g8yqvrh55gq0wds4hny1t94r0000gn/T/ruby-build.20210101111906.42540.uFRvAN
Results logged to /var/folders/x8/g8yqvrh55gq0wds4hny1t94r0000gn/T/ruby-build.20210101111906.42540.log

Last 10 log lines:
compiling ../.././ext/psych/yaml/parser.c
linking shared-object json/ext/parser.bundle
linking shared-object pathname.bundle
installing default psych libraries
linking shared-object json/ext/generator.bundle
linking shared-object bigdecimal.bundle
linking shared-object psych.bundle
linking shared-object nkf.bundle
linking shared-object date_core.bundle
make: *** [build-ext] Error 2`
Haemin answered 31/12, 2020 at 18:12 Comment(5)
Trying to install using this command: RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix [email protected])" rbenv install 2.2.2 – Haemin
I'd suggest inspecting the log file mentioned in the error message /var/folders/x8/g8yqvrh55gq0wds4hny1t94r0000gn/T/ruby-build.20210101111906.42540.log. It might have additional info that could be helpful. – Precipitin
See my updated answer. I don't use rbenv or ruby-build so can't speak to its efficacy. – Precipitin
"WARNING: ruby-2.2.2 is past its end of life and is now unsupported. It no longer receives bug fixes or critical security updates." Do you specifically need Ruby 2.2.2? – Gimbals
Thank you @Gimbals ! Yes, I am working on rebooting an older project. Learning how to upgrade to a newer Ruby version :) – Haemin
P
16

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,

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:

Precipitin answered 31/12, 2020 at 21:43 Comment(4)
Thank you @supremebeing7! I ran both brew install readline brew install zlib but, it looks like they are already installed and up-to-date. I reinstalled both readline and zlib, but still no luck :( – Haemin
Same error after reinstalling? How about using the commands from the linked github issues, e.g. RUBY_CONFIGURE_OPTS=--with-readline-dir="$(brew --prefix readline)" --with-zlib-dir="$(brew --prefix zlib)" – Precipitin
Oh wait, it looks like you updated the error message in your post? – Precipitin
Ah! I am sorry– I am new to Stack Overflow! I should have kept the original error. 😳 The original error was with Ruby readline/zlib. Error evolved to current description. CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.2.2 solved the problem! Thank you so much for your help, @Precipitin ! – Haemin

© 2022 - 2024 β€” McMap. All rights reserved.