Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jansroka/9710e4ebfce047bd980a5f33439cc6de to your computer and use it in GitHub Desktop.
Save jansroka/9710e4ebfce047bd980a5f33439cc6de to your computer and use it in GitHub Desktop.
Install ruby 3.1.0 with rbenv on OSX Monterey 12.5 Based on hours of fiddling and trying everything I could find and can think of. This is the config which worked for me.

Install ruby 3.1.0 with rbenv on OSX Monterey 12.5

Based on hours of fiddling and trying everything I could find and can think of. This is the config which worked for me.

1) You need to set these exports

# ruby
export PATH=/Users/jan/.rbenv/shims:$PATH
export optflags="-Wno-error=implicit-function-declaration"
export CFLAGS="-Wno-error=implicit-function-declaration"
export LDFLAGS="-L/usr/local/opt/libffi/lib $LDFLAGS"
export CPPFLAGS="-I/usr/local/opt/libffi/include $CPPFLAGS"
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig:$PKG_CONFIG_PATH"
export CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)"

# ruby-build
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1) --with-readline-dir=$(brew --prefix readline) --with-libyaml-dir=$(brew --prefix libyaml) --with-zlib-dir=$(brew --prefix zlib)"

# ruby - readline needs this
export LDFLAGS="-L/usr/local/opt/readline/lib $LDFLAGS"
export CPPFLAGS="-I/usr/local/opt/readline/include $CPPFLAGS"
export PKG_CONFIG_PATH="/usr/local/opt/readline/lib/pkgconfig:$PKG_CONFIG_PATH"

# ruby  - openssl needs this
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib $LDFLAGS"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include $CPPFLAGS"
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig:$PKG_CONFIG_PATH"
export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"

There is discussion onlie if you can concatenate LDFLAGS with a :or an .

2) You need to make sure your openssl path is correct

Check which opensl. The rbenv install only worked when it was set to /usr/local/opt/openssl@1.1/bin/openssl.

This is why you need to set export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"

Having these things taken care of rbenv install 3.1.0 succeeded without a problem.

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