Home » Ruby » OpenSSL error installing ruby 2.0.0-p195 on Mac with rbenv

OpenSSL error installing ruby 2.0.0-p195 on Mac with rbenv

Posted by: admin December 20, 2017 Leave a comment

Questions:

I’m trying to install Ruby 2.0.0-p195 using rbenv on a Mac (Mountain Lion) and got this error.

BUILD FAILED

Inspect or clean up the working tree at /var/folders/vt/27n8h2yj27v7rzq58075f3_m0000gn/T/ruby-build.20130618163859.1669
Results logged to /var/folders/vt/27n8h2yj27v7rzq58075f3_m0000gn/T/ruby-build.20130618163859.1669.log

Last 10 log lines:
installing default gems:      /Users/me/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0 (build_info, cache, doc, gems, specifications)
                              bigdecimal 1.2.0
                              io-console 0.4.2
                              json 1.7.7
                              minitest 4.3.2
                              psych 2.0.0
                              rake 0.9.6
                              rdoc 4.0.0
                              test-unit 2.0.0.0
The Ruby openssl extension was not compiled. Missing the OpenSSL lib?

When I ran brew install openssl it said

Warning: openssl-1.0.1e already installed

Following a solution on this thread https://github.com/sstephenson/ruby-build/issues/305 I tried to install latest stable this way and got the same error

env CFLAGS='-g -O2' RUBY_CONFIGURE_OPTS="--with-readline-dir=`brew --prefix readline`" rbenv install 2.0.0-p195

Any ideas?

Answers:

Try adding OpenSSL to the config options using the –with-openssl-dir option:

$ CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl`" rbenv install 2.0.0-p195

If you’re using Homebrew, you’ll need to install OpenSSL before running the above by running:

$ brew install openssl

UPDATE (see @JarkkoLaine ‘s comment below):

Just for the record, you should not need to use the config opts
anymore with ruby-build and homebrew. However, I had to reinstall
openssl with homebrew to make it work: brew uninstall openssl; brew
upgrade; brew install openssl; rbenv install 2.0.0-p247. See this for
more info.

Questions:
Answers:

I fixed this by executing:

brew link openssl --force

Mac OSX 10.9.4

Questions:
Answers:

Upgrading to the latest version of ruby-build fixed the problem for me:

Like the OP, I got

BUILD FAILED

Inspect or clean up the working tree at /Users/me/.rbenv/sources/2.0.0-p247
Results logged to /var/folders/3x/y_8y8vr53ws_kxj97km79q5h0000gn/T/ruby-build.20130704172404.3106.log

Last 10 log lines:
installing default gems:      /Users/me/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0 (build_info, cache, doc, gems, specifications)
                              bigdecimal 1.2.0
                              io-console 0.4.2
                              json 1.7.7
                              minitest 4.3.2
                              psych 2.0.0
                              rake 0.9.6
                              rdoc 4.0.0
                              test-unit 2.0.0.0
The Ruby openssl extension was not compiled. Missing the OpenSSL lib?

but installing the latest version of ruby-build, via

# Don't forget brew doctor and brew update if required
brew upgrade ruby-build

fixed it.

Ruby-build had some changes between when the OP asked and now, which would explain why it worked for me, but not for the OP using the latest stable version of ruby-build.

Questions:
Answers:

For those who have problems installing openssl.

I had this error on my Mac 10.8.4

brew install openssl

created directory `/usr/local/Cellar/openssl/1.0.1e/include/openssl'
make: *** [install_sw] Error 13

READ THIS: https://github.com/mxcl/homebrew/wiki/troubleshooting

These open issues may also help:
    https://github.com/mxcl/homebrew/pull/19429
  1. Create a directory if it does not exist

    sudo mkdir /usr/local/etc/openssl
    
  2. Change the rights. Replace and with your name and group (e.g. serge:admin)

    sudo chown -R <username>:<group> /usr/local/etc/openssl/
    
  3. Repeat openssl installation

    brew install openssl
    
  4. Install curl-ca-bundle

    brew install curl-ca-bundle
    
  5. install ruby

    CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl`" rbenv install 2.0.0-p195
    

Bingo

Questions:
Answers:

Solution using ruby-install:

After uninstalling and installing openssl a couple of times (probably unnecessary) I successfully tried this:

ruby-install ruby 2.1.3 -- --with-openssl-dir=`brew --prefix openssl`

Questions:
Answers:

The missing library is libssl*-dev* / openssl*-dev*, depending your distribution.

Questions:
Answers:

This issue came up again for me with Mac OS 10.9.5

Mac upgraded the command-line tools and that upgraded openssl, which broken rbenv.

I tried all of these solutions, but none of them worked. Everything was up-to-date, but I couldn’t install any new gems or build rubies.

My solution was to:

  1. Remove the ruby version (for me it was 2.1.1)
  2. Brew uninstall ruby-build and rbenv
  3. Brew Re-install rbenv and ruby-build

Hope this helps you if you encounter it too!