Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby install aborted due to missing extensions: openssl, readline, zlib compilation error

I'm using macOs Catalina. I'm trying to install older version of Ruby (1.9.3, 2.1.2) via rbenv. However, I keep getting the errors below, when trying installing older version. *It was fine when installing 2.4 or newer.

I already try

brew install openssl
brew install readline
brew install zlib

as well as brew update. I have everything installed and up-to-dated but still the errors below keeps coming up.

I also did tried to install with configure option

RUBY_CONFIGURE_OPTS="--with-readline-dir=`brew --prefix readline` --with-openssl-dir=`brew --prefix openssl`" rbenv install 2.1.2

Please let me know how I can fix this.

ruby-build: using readline from homebrew

BUILD FAILED (Mac OS X 10.15.7 using ruby-build 20201005)

Inspect or clean up the working tree at /var/folders/80/ts3rxpm5199g71p1vm4xzydj03b4g3/T/ruby-build.20201113153529.74484.A9uFGC Results logged to /var/folders/80/ts3rxpm5199g71p1vm4xzydj03b4g3/T/ruby-build.20201113153529.74484.log

Last 10 log lines: The Ruby openssl extension was not compiled. The Ruby readline extension was not compiled. The Ruby zlib extension was not compiled. ERROR: Ruby install aborted due to missing extensions Configure options used:
--prefix=/Users/username/.rbenv/versions/2.1.2
--with-openssl-dir=/usr/local/opt/[email protected]
--with-readline-dir=/usr/local/opt/readline
CC=clang
LDFLAGS=-L/Users/username/.rbenv/versions/2.1.2/lib
CPPFLAGS=-I/Users/username/.rbenv/versions/2.1.2/include

like image 307
hans1125 Avatar asked Nov 13 '20 07:11

hans1125


1 Answers

  1. ruby-build required clang 11 to install older version of ruby: GitHub comment link
    1. If clang is already updated to 12, you need to nuke it first: sudo rm -rf /Library/Developer/CommandLineTools (source GitHub comment)
    2. Then, install Command_Line_Tools_for_Xcode_11.5.dmg for clang 11 from official Apple Developers's website (required at least Free Apple Developer Account)
  2. Ensure openssl 1.0 is picked up while installing older version of ruby
    1. ruby-build installs appropriate openssl, eg. 2.1.2 build
    2. echo $RUBY_CONFIGURE_OPTS to ensure it's empty or set to use [email protected]
    3. If ruby-build still picks openssl 1.1, then you may explicitly brew install rbenv/tap/[email protected] and RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix [email protected])" (source GitHub comment)
like image 87
Parth Avatar answered Nov 15 '22 18:11

Parth