无法加载此类文件 - rufus-scheduler(LoadError)

时间:2015-03-27 11:51:07

标签: ruby-on-rails ruby passenger redmine rufus-scheduler

虽然我不想排除我可能会遗漏一些非常愚蠢的东西,但我确实尝试阅读了关于这个主题的所有内容,所以这就是我的问题:

我正在尝试在我的redmine(2.6)安装中运行rufus-scheduler,如下所述:http://www.redmine.org/projects/redmine/wiki/RedmineReceivingEmails#Schedule-email-receiving-with-Rufus-Scheduler

主机系统是CentOS 7 x64 + Plesk 12.

gem list显示rufus-scheduler (3.0.9)

重新启动redmine时,我收到以下错误日志:

cannot load such file -- rufus-scheduler (LoadError)
  /usr/local/share/gems/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:251:in `require'
  /usr/local/share/gems/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:251:in `block in require'
  /usr/local/share/gems/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:236:in `load_dependency'
  /usr/local/share/gems/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:251:in `require'
  /var/www/vhosts/klwr.de/redmine.klwr.de/redmine-2.6.1/config/initializers/emailhandler.rb:3:in `<top (required)>'
  /usr/local/share/gems/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:245:in `load'
  /usr/local/share/gems/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:245:in `block in load'
  /usr/local/share/gems/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:236:in `load_dependency'
  /usr/local/share/gems/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:245:in `load'
  /usr/local/share/gems/gems/railties-3.2.21/lib/rails/engine.rb:593:in `block (2 levels) in <class:Engine>'
  /usr/local/share/gems/gems/railties-3.2.21/lib/rails/engine.rb:592:in `each'
  /usr/local/share/gems/gems/railties-3.2.21/lib/rails/engine.rb:592:in `block in <class:Engine>'
  /usr/local/share/gems/gems/railties-3.2.21/lib/rails/initializable.rb:30:in `instance_exec'
  /usr/local/share/gems/gems/railties-3.2.21/lib/rails/initializable.rb:30:in `run'
  /usr/local/share/gems/gems/railties-3.2.21/lib/rails/initializable.rb:55:in `block in run_initializers'
  /usr/local/share/gems/gems/railties-3.2.21/lib/rails/initializable.rb:54:in `each'
  /usr/local/share/gems/gems/railties-3.2.21/lib/rails/initializable.rb:54:in `run_initializers'
  /usr/local/share/gems/gems/railties-3.2.21/lib/rails/application.rb:136:in `initialize!'
  /usr/local/share/gems/gems/railties-3.2.21/lib/rails/railtie/configurable.rb:30:in `method_missing'
  /var/www/vhosts/klwr.de/redmine.klwr.de/redmine-2.6.1/config/environment.rb:14:in `<top (required)>'
  config.ru:3:in `require'
  config.ru:3:in `block in <main>'
  /usr/local/share/gems/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
  /usr/local/share/gems/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
  config.ru:1:in `new'
  config.ru:1:in `<main>'
  /usr/local/share/gems/gems/passenger-4.0.59/helper-scripts/rack-loader.rb:108:in `eval'
  /usr/local/share/gems/gems/passenger-4.0.59/helper-scripts/rack-loader.rb:108:in `load_app'
  /usr/local/share/gems/gems/passenger-4.0.59/helper-scripts/rack-loader.rb:127:in `<module:App>'
  /usr/local/share/gems/gems/passenger-4.0.59/helper-scripts/rack-loader.rb:27:in `<module:PhusionPassenger>'
  /usr/local/share/gems/gems/passenger-4.0.59/helper-scripts/rack-loader.rb:26:in `<main>'

我的第一个猜测是我需要将以下指令之一应用于Apache:

RailsAppSpawnerIdleTime 0
PassengerMinInstances 1
PassengerSpawnMethod direct

但是,应用这些的任意组合只会更改错误日志,以便在rack-loader中但在rack-preloader中不会发生错误。

显示redmine的包内容不会显示rufus调度程序。这可能是一个原因吗? (如果是的话,这应该在redmine的一些文档中提到。)

这里是文件config / initializers / emailhandler.rb的完整内容:

require 'rubygems'
require 'rake'
require 'rufus-scheduler'

load File.join(Rails.root, 'Rakefile')

ENV['host']='xxx'
ENV['port']='25'
ENV['username']='xxx'
ENV['password']='xxx'
ENV['project']='xxx'
ENV['unknown_user']='accept'
ENV['no_permission_check']='1'

scheduler = Rufus::Scheduler.new
# Check emails every 1 mins
scheduler.in '1m' do
  task = Rake.application['redmine:email:receive_imap']
  task.reenable
  task.invoke
end

感谢您花时间阅读此内容以获取任何提示。祝你有美好的一天。

1 个答案:

答案 0 :(得分:1)

奇怪的是,作者建议在没有bundler的情况下直接安装gem。

我知道Redmine开始时它只能看到“捆绑”的宝石。这意味着我建议你添加一行

gem 'rufus-scheduler' 

到Gemfile,运行bundle install并尝试再次启动Redmine。