Skip to content

Instantly share code, notes, and snippets.

@bondarolik
Created January 11, 2021 14:54
Show Gist options
  • Save bondarolik/6806cccdfd187aff75665580c2401873 to your computer and use it in GitHub Desktop.
Save bondarolik/6806cccdfd187aff75665580c2401873 to your computer and use it in GitHub Desktop.
Unable to install ruby 2.2.2 with rbenv on macOS Big Sur

Ruby < 2.5 fails to install on macOS Big Sur with rbenv because xCode 12 removes outdated packages and it's impossible to rollback to xCode 11.5 and Commandline Tools older version than actual. There are few steps to fix this.

1. Add openssl@1.0.2 with brew

brew install rbenv/tap/openssl@1.0

# view more details at https://stackoverflow.com/questions/59337838/openssl-1-0-2m-on-macos

2. Install readline and zlib

Those libraries should be installed already on your system

3. Use specific flags to install Ruby < 2.4

RUBY_CONFIGURE_OPTS="--with-openssl-dir=/usr/local/opt/openssl@1.0 --with-readline-dir=$(brew --prefix readline)" CFLAGS="-Wno-error=implicit-function-declaration"  rbenv install 2.2.2

If fails, try this and repeat step 3.

export LDFLAGS="-L/usr/local/opt/readline/lib"
export CPPFLAGS="-I/usr/local/opt/readline/include"
export PKG_CONFIG_PATH="/usr/local/opt/readline/lib/pkgconfig"

This should help.

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