10

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/openssl@1.0
--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

hans1125
  • 357
  • 8
  • 15

3 Answers3

8
  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 openssl@1.0
    3. If ruby-build still picks openssl 1.1, then you may explicitly brew install rbenv/tap/openssl@1.0 and RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.0)" (source GitHub comment)
Parth
  • 729
  • 8
  • 23
2

Hi I also kept running into this on 'Mac OS X 10.15.7 using ruby-build' I had to set both of the following variables at the same time before the rbenv install 3.0.1 command:

OPENSSL_CFLAGS=-Wno-error=implicit-function-declaration RUBY_CONFIGURE_OPTS=--with-readline-dir="$(brew --prefix readline)" rbenv install 3.0.1

The first one tells the compiler to ignore where functions are implicitly declared rather than erroring out when this happens. And the second tells ruby which readline to use (in this case the one installed trough homebrew).

p.s. I also had set the openssl to 1.1.1

CodeLife
  • 89
  • 6
0

I've had issues installing Ruby on both Intel and M1 Macs. What's worked 100% of the time is ruby-install:

# install ruby-install from source
wget -O ruby-install-0.8.5.tar.gz https://github.com/postmodern/ruby-install/archive/v0.8.5.tar.gz
tar -xzvf ruby-install-0.8.5.tar.gz
cd ruby-install-0.8.5/
sudo make install

# install via homebrew (macOS)
brew install ruby-install openssl@1.1 readline zlib

# install specific version
ruby-install ruby 3.1.2

# install specific version (macOS)
ruby-install ruby-2.7.2 -- --with-openssl-dir=$(brew --prefix openssl@1.1)

# list rubies
ruby-install

# update all rubies
ruby-install --update

Not sure how far it goes back, as the CDN/FTP has to exist, but for v2.7.* it appears to have a long tail. Did have a 404 with 2.1.2:

>>> Downloading https://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.xz into /Users/lance.stephens/src ...
--2023-01-05 14:40:04--  https://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.xz
Resolving cache.ruby-lang.org (cache.ruby-lang.org)... 151.101.1.178, 151.101.65.178, 151.101.129.178, ...
Connecting to cache.ruby-lang.org (cache.ruby-lang.org)|151.101.1.178|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2023-01-05 14:40:05 ERROR 404: Not Found.

!!! Download of https://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.xz failed!

Stable versions as of today:

λ ruby-install
Stable ruby versions:
  ruby:
    2.6.8
    2.7.4
    3.0.2
  jruby:
    9.3.4.0
  rbx:
    5.0
  truffleruby:
    22.1.0
  truffleruby-graalvm:
    22.1.0
  mruby:
    3.0.0