2014-01-09 38 views
2

在IRB当我输入需要“引入nokogiri”时的错误,我得到以下错误:IRB显示“LoadError:无法加载这样的文件 - 引入nokogiri”试图规定“引入nokogiri”

LoadError: cannot load such file -- nokogiri 

我有nokogiri gem安装在我的gemfile中,并且可以在Rails中使用它,但在IRB中会引发错误。

我在OSX小牛队的情况下,帮助。

下面是我当地的宝石列表:加载任何其他宝石之前

actionmailer (4.0.2)
actionpack (4.0.2)
activemodel (4.0.2)
activerecord (4.0.2)
activerecord-deprecated_finders (1.0.3)
activesupport (4.0.2)
arel (4.0.1)
atomic (1.1.14)
builder (3.1.4)
bundler (1.3.5)
erubis (2.7.0)
hike (1.2.3)
i18n (0.6.9)
mail (2.5.4)
mime-types (1.25.1)
minitest (4.7.5)
multi_json (1.8.2)
polyglot (0.3.3)
rack (1.5.2)
rack-test (0.6.2)
rails (4.0.2)
railties (4.0.2)
rake (10.1.0)
sprockets (2.10.1)
sprockets-rails (2.0.1)
thor (0.18.1)
thread_safe (0.1.3)
tilt (1.4.1)
treetop (1.4.15)
tzinfo (0.3.38)

+0

我不知道你是否意识到,你没有在上面所列内容引入nokogiri;)尝试运行'束EXEC irb'所以你会用宝石从你的Gemfile。 – zrl3dx

+0

感谢您的建议。那为我工作。如果你创建一个答案,那么我会接受它。 – TaimoorQ

回答

4

所有你需要做的就是运行bundle exec irb使用宝石从Gemfile中。

0

您应该运行 require 'rubygems' 。 Rails为你做这件事,但IRB并不那么花哨。

否则,您使用的是像RVM这样的经理吗?你确认你没有切入或切出宝石吗?

+0

感谢您的答案,但返回false。我猜是因为它不在我的本地宝石中,只在rails应用程序gemfile中。我在注释中使用了zrl2dx的建议以使用gemfile中的gem,并且它工作了 – TaimoorQ

+1

'require'rubygems''从Ruby 1.8开始并不需要;并且在脚本中被广泛认为是有害的(但是反对意见在irb中可能并不重要)。 – echristopherson