为什么需要 mongo 给我 LoadError: no such file to load -- openssl [英] Why require mongo gives me LoadError: no such file to load -- openssl

查看:39
本文介绍了为什么需要 mongo 给我 LoadError: no such file to load -- openssl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Ubuntu Server 10、Ruby 1.9.2

I'm using Ubuntu Server 10, Ruby 1.9.2

当我尝试要求 'mongo'

When I try to require '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 所说:

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

sudo apt-get install libssl

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

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

那么在你编译ruby的时候它应该会被自动拾取.如果您不想重新编译 ruby​​,您应该能够通过

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 到包含 ruby​​ 源代码的文件夹
  • cd 到 ext/openssl
  • ruby extconf.rb
  • make &&须藤安装

这篇关于为什么需要 mongo 给我 LoadError: no such file to load -- openssl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆