运行 bundle 时出现“无法加载此类文件 -- openssl”

运行 bundle 时出现“无法加载此类文件 -- openssl”

当我尝试使用捆绑器,我收到错误:

/home/vivek/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': 无法加载此类文件 -- openssl (LoadError)

完整的错误消息如下。我该如何修复它?

Fetching gem metadata from https://rubygems.org/.Unfortunately, a fatal error has occurred. Please report this error to the Bundler issue tracker at https://github.com/carlhuda/bundler/issues so that we can fix it. Please include the full output of the command, your Gemfile and Gemfile.lock. Thanks!
/home/vivek/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- openssl (LoadError)
    from /home/vivek/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/vivek/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/https.rb:22:in `<top (required)>'
    from /home/vivek/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/vivek/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/vendor/net/http/persistent.rb:447:in `ssl'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/vendor/net/http/persistent.rb:216:in `connection_for'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/vendor/net/http/persistent.rb:358:in `request'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/fetcher.rb:135:in `fetch'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/fetcher.rb:163:in `fetch_dependency_remote_specs'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/fetcher.rb:122:in `fetch_remote_specs'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/fetcher.rb:70:in `specs'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/source.rb:234:in `block in remote_specs'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/source.rb:232:in `each'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/source.rb:232:in `remote_specs'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/source.rb:165:in `fetch_specs'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/source.rb:70:in `specs'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/definition.rb:205:in `block (2 levels) in index'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/definition.rb:202:in `each'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/definition.rb:202:in `block in index'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/index.rb:9:in `build'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/definition.rb:198:in `index'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/definition.rb:192:in `resolve'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/definition.rb:127:in `specs'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/definition.rb:122:in `resolve_remotely!'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/installer.rb:48:in `run'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/installer.rb:12:in `install'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/cli.rb:220:in `install'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/vendor/thor/task.rb:22:in `run'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/vendor/thor.rb:263:in `dispatch'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/vendor/thor/base.rb:386:in `start'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/bin/bundle:13:in `<top (required)>'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/bin/bundle:23:in `load'
    from /home/vivek/.rvm/gems/ruby-1.9.3-p194@global/bin/bundle:23:in `<main>'

答案1

以下教程建议使用 SSL 支持重新编译 Ruby:http://www.dinduks.com/rails-cannot-load-such-file-openssl

假设您使用 RVM,请按照以下步骤解决此问题。

安装 openssl 包

rvm pkg install openssl

删除你正在使用的 Ruby 安装

rvm remove 1.9.3

最后用 openssl 重新编译 Ruby

rvm install 1.9.3 --with-openssl-dir=$HOME/.rvm/usr

现在一切都应该正常工作了。别忘了:

rvm use 1.9.3 --default

这里还有一些链接,基本上建议做同样的事情:

相关内容