Search code examples
ruby-on-railsmacosmacos-catalinarbenv

rbenv install 2.7.1 fails on Mac OS Catalina using home-brew


I have been trying to install ruby for a few days now.

I installed home-brew checked that openssl@1.1 was installed.

I ran brew install rbenv and congfigure my zsh as follows,

local READLINE_PATH=$(brew --prefix readline)
local OPENSSL_PATH=$(brew --prefix openssl)
export LDFLAGS="-L$READLINE_PATH/lib -L$OPENSSL_PATH/lib"
export CPPFLAGS="-I$READLINE_PATH/include -I$OPENSSL_PATH/include"
export PKG_CONFIG_PATH="$READLINE_PATH/lib/pkgconfig:$OPENSSL_PATH/lib/pkgconfig"

# Use the OpenSSL from Homebrew instead of ruby-build
# Note: the Homebrew version gets updated, the ruby-build version doesn't
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$OPENSSL_PATH"

# Place openssl@1.1 at the beginning of your PATH (preempt system libs)
export PATH=$OPENSSL_PATH/bin:$PATH

# Load rbenv
eval "$(rbenv init -)"

# Extract the latest version of Ruby so you can do this:
# rbenv install $LATEST_RUBY_VERSION
export LATEST_RUBY_VERSION=$(rbenv install -l | grep -v - | tail -1)

When I try to run rbenv install 2.7.1 I get a build error. Saying it can't require openssl@1.1.

I checked it is installed and tried everything I can think of. This was tested on catalina 10.15 fresh install. I reformatted my computer and installed the Xcode command tools as well.

Here are the logs.

installing manpages:                /Users/main/.rbenv/versions/2.7.1/share/man (man1, man5)
installing default gems from lib:   /Users/main/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0 (build_info, cache, doc, extensions, gems, specifications)
                                    benchmark 0.1.0
/private/var/folders/cv/z8f4fy9171z64hl8vk4ms68h0000gn/T/ruby-build.20200617194325.10220.l3muIu/ruby-2.7.1/lib/rubygems/core_ext/kernel_require.rb:92:in `require': cannot load such file -- openssl (LoadError)
        from /private/var/folders/cv/z8f4fy9171z64hl8vk4ms68h0000gn/T/ruby-build.20200617194325.10220.l3muIu/ruby-2.7.1/lib/rubygems/core_ext/kernel_require.rb:92:in `require'
        from /private/var/folders/cv/z8f4fy9171z64hl8vk4ms68h0000gn/T/ruby-build.20200617194325.10220.l3muIu/ruby-2.7.1/lib/rubygems/specification.rb:2426:in `to_ruby'
        from ./tool/rbinstall.rb:846:in `block (2 levels) in install_default_gem'
        from ./tool/rbinstall.rb:279:in `open_for_install'
        from ./tool/rbinstall.rb:845:in `block in install_default_gem'
        from ./tool/rbinstall.rb:835:in `each'
        from ./tool/rbinstall.rb:835:in `install_default_gem'
        from ./tool/rbinstall.rb:799:in `block in <main>'
        from ./tool/rbinstall.rb:950:in `block in <main>'
        from ./tool/rbinstall.rb:947:in `each'
        from ./tool/rbinstall.rb:947:in `<main>'
make: *** [do-install-all] Error 1

Any help would be greatly appreciated I am getting pretty annoyed.


Solution

  • So what I ended up doing was I installed the entire Xcode package found online instead of through the App Store. Doing this helped solve my issue.