2010-11-16 223 views
1

我一直沒有找到解決辦法如下:Rails控制檯 - Hpricot,Nokogiri在Rails控制檯中不可用?

安裝寶石後,如hpricot或nokogiri,我無法在rails控制檯中訪問這些。寶石出現在我的寶石列表中,並且似乎與我的其他寶石有相同的路徑。

[email protected]:~$ which nokogiri 
/home/user/.rvm/gems/ruby-1.9.2-p0/bin/nokogiri 
[email protected]:~$ which rake 
/home/user/.rvm/gems/ruby-1.9.2-p0/bin/rake 

在控制檯,對於 「標準」 的寶石,他們能夠要求,例如:

ruby-1.9.2-p0 > require 'open-uri' 
=> ["OpenURI"] 

然而,需要引入nokogiri返回如下:

ruby-1.9.2-p0 > require 'nokogiri' 
LoadError: no such file to load -- nokogiri 
    from /home/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require' 
    from /home/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `block in require' 
    from /home/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:225:in `block in load_dependency' 
    from /home/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:591:in `new_constants_in' 
    from /home/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:225:in `load_dependency' 
    from /home/user/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require' 
    from (irb):10 
    from /home/user/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/commands/console.rb:44:in `start' 
    from /home/user/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/commands/console.rb:8:in `start' 
    from /home/user/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/commands.rb:23:in `<top (required)>' 
    from script/rails:9:in `require' 
    from script/rails:9:in `<main>' 

無論如何,我真的很感謝幫助我的新問題,一直在這一天的大部分時間裏掙扎。 :)

回答

3

您是否將寶石添加到Gemfile中?當控制檯啓動時,它們將自動加載。

+0

就是這樣!那..那真是令人尷尬。哈哈,我真的很感激它。 – Kombo 2010-11-16 21:22:46

+0

我很高興,它的工作,記得接受解決您的問題的答案,使他們不顯示爲解決了。 – 2010-11-16 21:45:18