Fix Ruby OpenSSL error, Symbol not found _SSLv2_client_method

  03 Nov 2014


After I upgraded OSX to Yosemite, aka, 10.10. I use bundle install as usual. For some reason, I got the following error:

    /Users/zdk/.rbenv/versions/2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': dlopen(/Users/zdk/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/x86_64-darwin13.0.0/openssl.bundle, 9): Symbol not found: _SSLv2_client_method (LoadError)
      Referenced from: /Users/zdk/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/x86_64-darwin13.0.0/openssl.bundle
      Expected in: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
     in /Users/zdk/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/x86_64-darwin13.0.0/openssl.bundle - /Users/zdk/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/x86_64-darwin13.0.0/openssl.bundle
            from /Users/zdk/.rbenv/versions/2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb

Some people got the above error after updating openssl library on Mac OS X too. And, there is a known suggestion to just re-install your Ruby version that has the above problem. So, with any luck, I do: rbenv install 2.0.0-p247

    Downloading ruby-2.0.0-p247.tar.gz...
    -> http://dqw8nmjcqpjn7.cloudfront.net/3e71042872c77726409460e8647a2f304083a15ae0defe90d8000a69917e20d3
    Installing ruby-2.0.0-p247...

Boom!

    BUILD FAILED

    Inspect or clean up the working tree at /var/folders/2c/4szm6d893_n2gd2d_hs8_3qr0000gn/T/ruby-build.20141103155101.28336
    Results logged to /var/folders/2c/4szm6d893_n2gd2d_hs8_3qr0000gn/T/ruby-build.20141103155101.28336.log

    Last 10 log lines:
    configure: WARNING: unrecognized options: --with-libyaml-dir, --with-openssl-dir, --with-readline-dir
    checking build system type... x86_64-apple-darwin14.0.0
    checking host system type... x86_64-apple-darwin14.0.0
    checking target system type... x86_64-apple-darwin14.0.0
    checking for gcc-4.2... gcc-4.2
    checking for gcc... (cached) gcc-4.2
    checking whether the C compiler works... no
    configure: error: in `/var/folders/2c/4szm6d893_n2gd2d_hs8_3qr0000gn/T/ruby-build.20141103155101.28336/ruby-2.0.0-p247’:
    configure: error: C compiler cannot create executables
    See `config.log’ for more details

    BUILD FAILED

    Inspect or clean up the working tree at /var/folders/2c/4szm6d893_n2gd2d_hs8_3qr0000gn/T/ruby-build.20141103155101.28336
    Results logged to /var/folders/2c/4szm6d893_n2gd2d_hs8_3qr0000gn/T/ruby-build.20141103155101.28336.log

    Last 10 log lines:
    configure: WARNING: unrecognized options: --with-libyaml-dir, --with-openssl-dir, --with-readline-dir
    checking build system type... x86_64-apple-darwin14.0.0
    checking host system type... x86_64-apple-darwin14.0.0
    checking target system type... x86_64-apple-darwin14.0.0
    checking for gcc-4.2... gcc-4.2
    checking for gcc... (cached) gcc-4.2
    checking whether the C compiler works... no
    configure: error: in `/var/folders/2c/4szm6d893_n2gd2d_hs8_3qr0000gn/T/ruby-build.20141103155101.28336/ruby-2.0.0-p247’:
    configure: error: C compiler cannot create executables
    See `config.log’ for more details

Well, why on my machine doesn’t work? After I read the log, it looks like something on my machine went wrong with the current gcc (installed with Homebrew). I think Ruby build was trying to find C compiler and found the Homebrew’s apple-gcc42, then it failed. The following is the version that ruby-build just found:

    λ zdk ⮀ ~ gcc-4.2 --version
    couldn't understand kern.osversion `14.0.0'
    i686-apple-darwin11-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
    Copyright (C) 2007 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

The workaround that works for me is: export CC=/usr/bin/gcc

    λ zdk ⮀ ~ gcc --version
    Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1
    Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
    Target: x86_64-apple-darwin14.0.0
    Thread model: posix

And try to install ruby with rbenv install 2.0.0-p247

    Downloading ruby-2.0.0-p247.tar.gz...
    -> http://dqw8nmjcqpjn7.cloudfront.net/3e71042872c77726409460e8647a2f304083a15ae0defe90d8000a69917e20d3
    Installing ruby-2.0.0-p247...
    Installed ruby-2.0.0-p247 to /Users/zdk/.rbenv/versions/2.0.0-p247

Finally, bundle install without any error :)

    Fetching gem metadata from https://rubygems.org/........
    Fetching additional metadata from https://rubygems.org/..
    Resolving dependencies...
    Installing addressable 2.3.6
    Installing multipart-post 2.0.0
    Installing faraday 0.9.0
    Installing berkshelf-api-client 1.2.0
    Installing buff-extensions 1.0.0
    Installing hashie 2.1.2
    Installing varia_model 0.4.0
    Installing buff-config 1.0.1

Additionally, alternative workarounds should also work:

RUBY_CONFIGURE_OPTS=”--without-gcc --disable-install-rdoc” rbenv install 2.1.0.0-p247

or

CC=”/usr/bin/clang” rbenv install 2.1.0.0-p247

comments powered by Disqus