【问题标题】:Issue installing Nokogiri Gem w/ Rails: "Could not find "Nokogiri..."使用 Rails 安装 Nokogiri Gem 时出现问题:“找不到“Nokogiri ...”
【发布时间】:2011-04-25 18:47:26
【问题描述】:

Nokogiri 在我的 gem 文件中。 Bundle install 返回预期的输出:

Using nokogiri (1.4.4) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

尝试执行 db:create:all 时出现以下错误:

rake db:create:all
Could not find nokogiri-1.4.4 in any of the sources

如果我在 irb 中测试,我也会得到预期的输出。

irb(main):003:0> require "rubygems"
=> true
irb(main):004:0> require "nokogiri"
=> true

我已多次卸载并安装 nokogiri 及其依赖项。

我正在使用:

导轨 3.0.6 红宝石 1.8.7

任何帮助将不胜感激。

编辑:美国东部时间 2011 年 4 月 25 日下午 3:02

对于下面的评论: nokogiri 的 Gemfile 行是

gem "nokogiri", '1.4.4', :require => "nokogiri"

【问题讨论】:

  • 你的 Gemfile 是什么样的?
  • 您的GEM_HOME 设置为什么?它可能安装在不寻常的地方,而 Ruby 找不到它。 Rakefile 使用 Gemfile,但您的 irb 示例没有。
  • 如何检查我的 GEM_HOME 也设置了什么?

标签: ruby ruby-on-rails-3 rake nokogiri bundler


【解决方案1】:

我根据您的情况做了一个测试。
我的 Gemfile 是这样的:

gem "nokogiri", '1.4.4', :require => "nokogiri"

然后rake db:migrate 工作得很好

【讨论】:

  • Nokogiri 已经在 gemfile 中,但我添加了 ":require => "nokogiri"" 段。 Rake db:migrate 和 Rake db:create:all 仍然返回:“在任何源中都找不到 nokogiri-1.4.4”
  • 这对我有用。我认为问题可能在于,即使我有 nokogiri 宝石,它也只是作为水豚的依赖项,或者我的 Gemfile 的 :test 块中的其他宝石之一,所以它没有出现在我的开发环境中。
【解决方案2】:

这可能是一个长镜头,但你可以尝试:

bundle install --no-deployment

如果您处于部署模式,Rails 将在供应商目录中查找您的 gem,而不是通常的安装位置。它可能会导致这种错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-08
    • 1970-01-01
    • 2019-01-08
    • 2015-11-13
    • 2015-02-14
    • 2016-02-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多