Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why require mongo gives me LoadError: no such file to load -- openssl

Tags:

ruby

I'm using Ubuntu Server 10, Ruby 1.9.2

When I try to require 'mongo'

it gives me this error:

irb(main):001:0> require 'mongo'
LoadError: no such file to load -- openssl
    from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /usr/local/lib/ruby/gems/1.9.1/gems/mongo-1.5.2/lib/mongo/util/ssl_socket.rb:1:in `<top (required)>'
    from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /usr/local/lib/ruby/gems/1.9.1/gems/mongo-1.5.2/lib/mongo.rb:63:in `<top (required)>'
    from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
    from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
    from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
    from (irb):1
    from /usr/local/bin/irb:12:in `<main>'
like image 232
mko Avatar asked Dec 27 '11 07:12

mko


1 Answers

You need two things: OpenSSL itself and the ruby bindings for OpenSSL. The first part is as Yossi said:

sudo apt-get install libssl

The second depends on how you install ruby. I'm guessing from the paths in your question that you compiled ruby from source. In which case you first need to make sure you have then openssl headers:

sudo apt-get install libssl-dev

then it should be picked up automatically when you compile ruby. If you do not want to recompile ruby, the you should be able to build the OpenSSL bindings by

  • cd to the folder containing the ruby source
  • cd to ext/openssl
  • ruby extconf.rb
  • make && sudo make install
like image 194
Frederick Cheung Avatar answered Sep 29 '22 04:09

Frederick Cheung