我们有一个 rake 任务在数据库系统之间运行复杂的转换。我们已经升级了现在需要 Nokogiri 的任务。它已安装:
`gem list --local`:
*** LOCAL GEMS ***
...
nokogiri (1.5.9)
...
Ruby 是 1.8.x 版本,需要require 'rubygems'
:
`ruby -v`
ruby 1.8.7 (2012-02-08 MBARI 8/0x8770 on patchlevel 358) [i686-linux], MBARI 0x8770, Ruby Enterprise Edition 2012.02
使用 irb,一切似乎都很好:
`irb`
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'nokogiri'
=> true
irb(main):003:0>
但是,启动 rake 任务时,似乎没有找到 nokogiri:
lib/tasks$ RAILS_ENV="test" rake redmine::migrate_from_buggy_new.rake 280 --trace
(in /var/www/redmine)
rake aborted!
no such file to load -- nokogiri
/var/www/redmine/lib/tasks/migrate_from_buggy_new.rake:27:in `require'
/var/www/redmine/lib/tasks/migrate_from_buggy_new.rake:27
/usr/local/lib/ruby/gems/1.8/gems/railties-3.2.12/lib/rails/engine.rb:425:in `load'
/usr/local/lib/ruby/gems/1.8/gems/railties-3.2.12/lib/rails/engine.rb:425:in `load_tasks'
/usr/local/lib/ruby/gems/1.8/gems/railties-3.2.12/lib/rails/engine.rb:425:in `each'
/usr/local/lib/ruby/gems/1.8/gems/railties-3.2.12/lib/rails/engine.rb:425:in `load_tasks'
/usr/local/lib/ruby/gems/1.8/gems/railties-3.2.12/lib/rails/application.rb:145:in `load_tasks'
/usr/local/lib/ruby/gems/1.8/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `send'
/usr/local/lib/ruby/gems/1.8/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
/var/www/redmine/Rakefile:7
/usr/local/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/rake_module.rb:25:in `load'
/usr/local/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/rake_module.rb:25:in `load_rakefile'
/usr/local/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:583:in `raw_load_rakefile'
/usr/local/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:89:in `load_rakefile'
/usr/local/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/usr/local/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:88:in `load_rakefile'
/usr/local/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:72:in `run'
/usr/local/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/usr/local/lib/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/usr/local/lib/ruby/gems/1.8/gems/rake-10.0.3/bin/rake:33
/usr/local/bin/rake:19:in `load'
/usr/local/bin/rake:19
我不知道接下来要做什么,我对 Ruby 环境很陌生,一切仍然陌生而新鲜。
编辑: rake 文件的开头如下所示:
require 'active_record'
require 'action_controller'
require 'iconv'
require 'pp'
require 'rubygems'
require 'nokogiri'
namespace :redmine do
desc 'Buggy migration script'
task :migrate_from_buggy => :environment do
编辑 2:Nokogiri 安装到/usr/local/lib/ruby/gems/1.8/gems/nokogiri-1.5.9/lib/nokogiri
. 我试图将它包含在搜索路径中,如下所示:
RAILS_ENV="test" rake redmine::migrate_from_buggy_new.rake 280 -I "/usr/local/lib/ruby/gems/1.8/gems/"
RAILS_ENV="test" rake redmine::migrate_from_buggy_new.rake 280 -I "/usr/local/lib/ruby/gems/1.8/gems/nokogiri-1.5.9"
RAILS_ENV="test" rake redmine::migrate_from_buggy_new.rake 280 -I "/usr/local/lib/ruby/gems/1.8/gems/nokogiri-1.5.9/lib"
RAILS_ENV="test" rake redmine::migrate_from_buggy_new.rake 280 -I "/usr/local/lib/ruby/gems/1.8/gems/nokogiri-1.5.9/lib/nokogiri"
一切都无济于事(同样的问题/错误消息)。