Ubuntu – Install Ruby 2.0 with OpenSSL and ReadLine support

ruby

I have a fresh Ubuntu 12.04 VM, and I would like to install Ruby 2.0.0-p0. I am able to get Ruby installed easily enough, but I am unable to get gems to work.

$ gem install bundler
ERROR:  Loading command: install (LoadError)
cannot load such file -- openssl
ERROR:  While executing gem ... (NoMethodError)
    undefined method `invoke_with_build_args' for nil:NilClass

I have open SSL installed, so I'm not exactly sure what the problem is.

$ sudo apt-get install libssl1.0.0 libssl-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libssl-dev is already the newest version.
libssl1.0.0 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Similarly,

$ which openssl
/usr/bin/openssl

If I go back to the installation, there are two lines that concern me.

$ sudo make install
Failed to configure openssl. It will not be installed.
Failed to configure readline. It will not be installed.

Thanks!

Best Answer

In your source location, cd ext/openssl and then ruby extconf.rb. This will generate a makefile in the ext/openssl directory. Simply make && sudo make install it to build the ruby openssl extension, and install the .so into the appropriate location.

Ditto ext/readline for readline support.

Then you should be able to make ruby properly.

Edit: in case I wasn't clear enough:

pushd ext/openssl
ruby extconf.rb
make && sudo make install
popd

pushd ext/readline
ruby extconf.rb
make && sudo make install
popd

make
sudo make install
Related Question