15

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?

BrainLikeADullPencil
  • 11,313
  • 24
  • 78
  • 134

7 Answers7

29

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.

Amir
  • 1,882
  • 17
  • 22
  • I had to also do `brew install curl-ca-bundle; export SSL_CERT_FILE=/usr/local/opt/curl-ca-bundle/share/ca-bundle.crt` to get it to work. – Sam Soffes Nov 16 '13 at 16:09
  • 2
    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](https://github.com/sstephenson/ruby-build/issues/377#issuecomment-27159797) for more info. – Jarkko Laine Jan 09 '14 at 12:58
  • @JarkkoLaine 's solution of re-installing openssl via homebrew solved it for me (and after re-installing, I don't need to set the env variable either). I suspect it might be related to me recently upgrading to OS X Mavericks, which modified a lot of file permissions and ownerships in /usr/local. Perhaps you could consider promoting this comment to an answer, to make it easier to spot? – Eric Hansander Jun 20 '14 at 10:18
8

I fixed this by executing:

brew link openssl --force

Mac OSX 10.9.4

gotnull
  • 26,454
  • 22
  • 137
  • 203
6

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.

Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
  • Make sure you run `brew update` to update your formulae so you get the latest version of `ruby-build` when you upgrade/install :) – electblake Jul 18 '13 at 19:44
  • @electblake I noted that above the command for "brew upgrade ruby-build". – Andrew Grimm Jul 22 '13 at 04:13
  • 1
    I just installed the latest brew with rbenv and ruby-build and this didn't work unfortunately... – wik Aug 29 '13 at 14:29
  • 1
    Voted up because upgrading ruby-build solved this for me! I installed rbenv via git (not Brew,) however I did essentially the same thing as @Andrew by directly upgrading rbenv and ruby-build: `$ cd ~/.rbenv` `$ git pull` `$ cd ~/.rbenv/plugins/ruby-build` `$ git pull` When I ran "rbenv install 2.0.0-p353" the first thing that happened was that a new version of openssl was installed, and the ruby install worked fine. As a side-benefit, upgrading ruby-build also updated my list of installable Ruby versions. – Tom Wilson Dec 31 '13 at 16:42
3

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

Midwire
  • 1,090
  • 8
  • 25
Sergiy Seletskyy
  • 16,236
  • 7
  • 69
  • 80
  • Step 1 fixed it for me. I actually did these steps with brew install openssl running, and the directory was made just in time I guess because at the point when it usually failed, the brew install kept going! Bingo – Shane Sep 08 '13 at 15:10
1

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`
mrtnf
  • 132
  • 2
  • 5
0

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

tvial
  • 612
  • 5
  • 9
0

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!

awsmsce
  • 187
  • 9