`require’: cannot load such file — openssl (LoadError)


When your ruby and rails tools are installed, you will need to create a rails project. To do this use the rails command

rails new /var/www/rails-project

The following error was noticed when trying to create a rails project


/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- openssl (LoadError)

The problem is that the openssl-devel package was missing from our system. Often times linux systems contain the openssl package, however, this does not contain the correct header files that are necessary.

[showads ad=midpost]

The openssl-devel package luckily has everything needs, and is generally a good thing to install. This package can easily be installed using

yum install openssl-devel

The issue now is that ruby requires that this package be present during installation. Meaning we will need to re-install ruby and ruby gems. Perform the installation process again

For the ruby installation

./configure --prefix=/usr/local
make
make install

And to install ruby gems, change directory to the ruby gems package and

ruby setup.rb

Now we can execute the rails new command once again. After successful installation of the project, you should see

Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

Now you can begin your ruby and rails development. See you project install directory for more details.