Skip to content

Instantly share code, notes, and snippets.

@timcharper
Last active December 18, 2015 11:49
Show Gist options
  • Save timcharper/5778185 to your computer and use it in GitHub Desktop.
Save timcharper/5778185 to your computer and use it in GitHub Desktop.
For rbenv and without using ruby-build, how to install ruby-2.0.0-p195 with a working openssl.

ruby-build failed me, so I took matters into my own hands. Here's what worked

download and extract ruby 2.0.0p-195 to ~/.rbenv/src/ruby-2.0.0p195

mkdir $HOME/.rbenv/src
cd $HOME/.rbenv/src
wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p195.tar.gz
tar xzf ruby-2.0.0-p195.tar.gz

Install openssl-0.9.8 with homebrew (assumes homebrew is installed to /usr/local)

cd /usr/local/Library
git checkout a2e8b543f16745025001790777770b190b5d9a64
brew install openssl
git checkout master # switch it back

Build ruby. (openssl will fail)

cd ~/.rbenv/src/ruby-2.0.0-p195
./configure --prefix=$HOME/.rbenv/versions/2.0.0-p195
make -j 8 # cores * (hyperthreading ? 2 : 1)
make install

set to use ruby interpreter. At this point, ruby 2.0 works but openssl library will not load.

rbenv local 2.0.0-p195

Build openssl against openssl-0.9.8:

cd ext/openssl
ruby extconf.rb  --with-openssl-dir='/usr/local/Cellar/openssl/0.9.8/'
make
make install

You should have fully functioning ruby 2.0 with openssl!

@timcharper
Copy link
Author

I've tried building against openssl 1.0.1 and later, without success. This is the error I would get:

compiling openssl_missing.c
In file included from openssl_missing.c:22:
openssl_missing.h:71: error: conflicting types for ‘HMAC_CTX_copy’
/usr/local/opt/openssl/include/openssl/hmac.h:102: error: previous declaration of ‘HMAC_CTX_copy’ was here
openssl_missing.h:95: error: conflicting types for ‘EVP_CIPHER_CTX_copy’
/usr/local/opt/openssl/include/openssl/evp.h:502: error: previous declaration of ‘EVP_CIPHER_CTX_copy’ was here
openssl_missing.c:27: error: conflicting types for ‘HMAC_CTX_copy’
/usr/local/opt/openssl/include/openssl/hmac.h:102: error: previous declaration of ‘HMAC_CTX_copy’ was here
openssl_missing.c:122: error: conflicting types for ‘EVP_CIPHER_CTX_copy’
/usr/local/opt/openssl/include/openssl/evp.h:502: error: previous declaration of ‘EVP_CIPHER_CTX_copy’ was here
make: *** [openssl_missing.o] Error 1

@scottmagdalein
Copy link

@timcharper Have you made any progress? No solutions are working for me with Ruby 2.0.0-p247 and openssl 1.0.1e.

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