4

I have the following schedule.rb

every 1.minute do
  runner "User.persist_things"
end

But looking at my log/cron.log file, the output is the following:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- bundler/setup (LoadError)
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from /Users/felipeclopes/projects/example/config/boot.rb:6
    from script/rails:5:in `require'
    from script/rails:5

I am using RVM with ruby, the current version is:

$ ruby --version
ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-darwin10.8.0]

So it seems that the cron job is loading the incorrect ruby version, but I don't know how to fix this. Can you help me figuring out?

felipeclopes
  • 4,010
  • 2
  • 25
  • 35

3 Answers3

5

There is a known issue with whenever and rvm integration. I would suggest following the instructions on the whenever gem page: RVM Integration

See also: Whenever issues related to rvm

Carlos Drew
  • 1,633
  • 9
  • 17
  • The rvmrc file is deprecated and I am using the .ruby-version and .gemset-version, but it is not working. – felipeclopes Oct 16 '13 at 16:24
  • Hmm, at this point, then, I would suggest uninstalling all version of Ruby, and uninstalling all gemsets, and starting from scratch. It looks to me that whenever/cron are not respecting .ruby-version and .gemset-version, and instead using the default ruby/gemset. – Carlos Drew Oct 17 '13 at 00:10
0

You could ditch RVENV switch to something cleaner like rbenv + rbenv-binstubs

Andrew Hacking
  • 6,296
  • 31
  • 37
0

You should have this in config/deploy.rb to make whenever work with capistrano if that's the case:

require 'whenever/capistrano'
...
set :whenever_command, 'bundle exec whenever'
Antiarchitect
  • 1,852
  • 2
  • 16
  • 19