简体   繁体   中英

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

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

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.

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

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

sudo apt-get install libssl-dev
./configure --prefix=/usr/local
make
make install

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM