12

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 <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.beginrescueend.com/]

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

Please help me to resolve this issue.

Amit Patel
  • 15,609
  • 18
  • 68
  • 106
  • 1
    [This link](http://beginrescueend.com/packages/openssl/) may be helpful. Possible duplicate: [http://stackoverflow.com/questions/5515331/no-such-file-to-load-openssl](http://stackoverflow.com/questions/5515331/no-such-file-to-load-openssl). – Aliaksei Kliuchnikau Feb 02 '12 at 11:56
  • I tried suggested link but still getting same error. I re-installed both ruby and rails but no luck yet. – Amit Patel Feb 02 '12 at 12:23
  • I missed one step `rvm package install openssl`. I again follow all steps and the error gone. Thanks – Amit Patel Feb 02 '12 at 12:55

5 Answers5

13

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..

pdu
  • 10,295
  • 4
  • 58
  • 95
  • 1
    are you sure the --with-openssl-dir=[path] is the right path where openssl is? and have you installed openssl and the openssl headers / devel packages? – pdu Feb 02 '12 at 12:32
  • You catch me. By using your suggestions and the link shared by Alex Kliuchnikau finally got openssl error gone. Thanks – Amit Patel Feb 02 '12 at 12:54
  • in 64bit system do: sudo apt-get install libssl-dev && rvm reinstall 1.9.3 --with-openssl-dir=/usr/lib/x86_64-linux-gnu/ – Yonatan Maman Apr 25 '12 at 10:01
  • 1
    Linux Mint 12. sudo apt-get install openssl && rvm reinstall 1.9.3 --with-openssl-dir=/usr/local – Anders B Apr 25 '12 at 19:05
  • If you're on Ubuntu, and the "rvm reinstall" command isn't recognized, you may need to follow these steps: http://stackoverflow.com/questions/9056008/installed-ruby-1-9-3-with-rvm-but-command-line-doesnt-show-ruby-v/9056395#9056395 – Templar May 18 '13 at 20:22
8

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.

Community
  • 1
  • 1
Francisco Quintero
  • 730
  • 1
  • 13
  • 20
8

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
Patrick Cullen
  • 8,654
  • 3
  • 21
  • 23
  • 1
    I confirm this to be working on Ubuntu 12.10 as well. I used the *reinstall* variant like so: `sudo apt-get install libssl-dev && rvm reinstall 1.9.3` – user569825 Sep 23 '12 at 18:56
4

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

sudo apt-get install libssl-dev
./configure --prefix=/usr/local
make
make install
Ry-
  • 218,210
  • 55
  • 464
  • 476
0

Here are instructions for Mac OS 10.8 (although, these seem general) https://gist.github.com/joneslee85/5025729

rvm pkg install openssl
rvm reinstall 1.9.3 --with-openssl-dir=$rvm_path/usr
vish
  • 2,436
  • 1
  • 24
  • 20