【问题标题】:Should I add files that are part of the Ruby Standard Library to the `Gemfile`?我应该将属于 Ruby 标准库的文件添加到“Gemfile”吗?
【发布时间】:2011-01-24 02:26:33
【问题描述】:

我需要在我的代码中使用require 'openssl'。否则,我会得到NameError: uninitialized constant Object::OpenSSL。但是,当我执行gem list 时,我看不到openssl。我正在将 Sinatra 应用程序部署到 Heroku 堆栈竹 mri-1.9.2。我应该将openssl 添加到Gemfile 吗?我不这么认为,因为我认为openssl is part of the Ruby Standard Library。还有,base64呢?

【问题讨论】:

    标签: ruby rubygems heroku openssl bundler


    【解决方案1】:

    对于您支持的 Ruby 版本,您不需要在 Gemfile 中包含 Ruby 标准库中的 gem

    您可以让您的程序自动要求 Gemfile 中的所有 gem。 Rails 就是这样做的。否则,只需在需要它的文件中添加require 'gem_name'

    【讨论】:

      【解决方案2】:

      很可能你编译了没有 openssl 支持的 ruby​​。如果你使用的是 RVM,可以试试this

      【讨论】:

      • 不,一切正常。我只是想知道是否还应该将 opensslbase64 添加到 gem 文件中。
      猜你喜欢
      • 2020-04-28
      • 2018-12-04
      • 1970-01-01
      • 1970-01-01
      • 2010-10-30
      • 1970-01-01
      • 2011-06-13
      • 2017-05-24
      • 1970-01-01
      相关资源
      最近更新 更多