Could not find bundler (>= 0) amongstを解決する。

webminのcommand shellから

bundle exec rake redmine:check_periodictasks RAILS_ENV="production"

のようなコマンドを発行して、redmineに定期チケットを登録しようとするのだけど、以下のようなエラーがでてうまくいかない。

# cd /var/lib/redmine; bundle exec rake redmine:check_periodictasks RAILS_ENV="production"

/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find bundler (>= 0) amongst [bigdecimal-1.1.0, io-console-0.3, json-1.5.4, minitest-2.5.1, rake-0.9.2.2, rdoc-3.9.4] (Gem::LoadError)
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems.rb:1231:in `gem'
from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/bundle:18:in `<main>'
from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_executable_hooks:15:in `eval'
from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_executable_hooks:15:in `<main>'

同じコマンドをターミナルから発行してみると問題ないので、環境変数にあたりをつけて確認したところ、GEM_HOMEが設定されていないことに気が付きました。

# crontab -l

GEM_HOME = /usr/local/rvm/gems/ruby-1.9.3-p194
@hourly cd /var/lib/redmine; bundle exec rake redmine:check_periodictasks RAILS_ENV="production"

Cronで動かすことが主目的だったので、GEM_HOMEを設定することで問題は解消されました。