2

在 rails 交互式 shell ( rails c) 中,我收到一条错误消息:No such file to load -- Mechanize'当我运行require 'mechanize'.

奇怪的是,当我进入require 'mechanize'ruby​​ shell ( irb) 时,我没有收到任何错误。

示例输出如下所示:

    rails c 
    Loading development environment (Rails 4.0.2)
    irb(main):001:0> require 'mechanize'
    LoadError: cannot load such file -- mechanize
     from /home/********/.gem/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
     from /home/********/.gem/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `block in require'
      from /home/********/.gem/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
      from /home/********/.gem/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
from (irb):1
      from /home/********/.gem/ruby/2.1.0/gems/railties-4.0.2/lib/rails/commands/console.rb:90:in `start'
      from /home/********/.gem/ruby/2.1.0/gems/railties-4.0.2/lib/rails/commands/console.rb:9:in `start'
      from /home/********/.gem/ruby/2.1.0/gems/railties-4.0.2/lib/rails/commands.rb:62:in `<top (required)>'
      from bin/rails:4:in `require'
      from bin/rails:4:in `<main>'

问候

4

1 回答 1

3

将此添加到 Gemfile

gem 'mechanize'

然后在shell上执行这个命令

bundle 
于 2014-01-31T05:02:06.110 回答