ruby – 为什么要求mongo给我LoadError:没有这样的文件要加载 – openssl

前端之家收集整理的这篇文章主要介绍了ruby – 为什么要求mongo给我LoadError:没有这样的文件要加载 – openssl前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用Ubuntu Server 10,Ruby 1.9.2

当我试图要求’mongo’时

它给了我这个错误

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

解决方法

您需要两件事:OpenSSL本身和OpenSSL的ruby绑定.第一部分是Yossi说的:
sudo apt-get install libssl

第二个取决于你如何安装ruby.我猜你的问题中的路径是你从源代码编译ruby.在这种情况下,您首先需要确保您有openssl标头:

sudo apt-get install libssl-dev

然后它应该在编译ruby时自动拾取.如果您不想重新编译ruby,那么您应该能够构建OpenSSL绑定

> cd到包含ruby源的文件夹> cd到ext / openssl> ruby​​ extconf.rb> make&& sudo make install

猜你在找的Ruby相关文章