Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while creating new Rails 3 project : `require': cannot load such file -- openssl (LoadError)

When I try to create a new project($ rails new first_app) it gives following error after creating directory structure.

...
...
      create  vendor/plugins/.gitkeep
         run  bundle install
/home/amit/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- openssl (LoadError)
    from /home/amit/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/amit/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/https.rb:22:in `<top (required)>'
...
...

Here is the configuration on Ubuntu 10.04

$ rails -v
Rails 3.2.1
$ rvm -v

rvm 1.10.2 by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.beginrescueend.com/]

$ bundle -v
Bundler version 1.0.21
$ gem -v
1.8.15

Please help me to resolve this issue.

like image 514
Amit Patel Avatar asked Feb 02 '12 11:02

Amit Patel


4 Answers

You need to bundle your ruby with openssl support. Have a look at http://beginrescueend.com/packages/openssl/

rvm reinstall 1.9.3 --with-openssl-dir=/usr/local

This requires that you have the openssl headers present on your box. These are named differently across the systems, like libopenssl-dev, libssl-dev, openssl-devel etc..

like image 178
pdu Avatar answered Nov 07 '22 03:11

pdu


Had the same problem on Ubuntu Lucid (10.04). Fixed with:

sudo apt-get install libssl-dev
rvm remove 1.9.3
rvm install 1.9.3
like image 36
Patrick Cullen Avatar answered Nov 07 '22 04:11

Patrick Cullen


This solution I saw in this link worked for me very well.

Assuming RVM is in use

rvm pkg install openssl

Remove ruby

rvm remove 1.9.3

And finally recompile Ruby with openssl

rvm install 1.9.3 --with-openssl-dir=$HOME/.rvm/usr

Finally

rvm use 1.9.3 --default

I hope this worked for future searches.

like image 8
Francisco Quintero Avatar answered Nov 07 '22 05:11

Francisco Quintero


If you're not using RVM, here's how:

sudo apt-get install libssl-dev
./configure --prefix=/usr/local
make
make install
like image 4
Ry- Avatar answered Nov 07 '22 03:11

Ry-