4

I have been using the whenever gem on my 2+ year old slice at Slicehost. I can't however do the same on my new slice.

Main differences is that I'm now running RVM on both my MBP and the slice. I am also running Rails 3. I've got Rubygems v 1.5.0 and latest versions of RVM , Ruby 1.9.2p136, Capistrano and about every other package out there.

I have tried a million things, read all the docs and as of now I'm using the whenever gem version 0.6.2. I have also looked at all questions on related topics on SO as well as Google.

Here is the code in deploy.rb:

namespace :deploy do
  ...
  desc "Update the crontab file"
  task :update_crontab, :roles => :db do
    run "cd #{release_path} && whenever --update-crontab #{application}"
  end   
end

after 'deploy:update_code', 'deploy:update_crontab'

Here is the error message I get after running 'cap deploy'

failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '1.9.2' -c 'cd /home/deploy/public_html/lasource/releases/20110209201551 && /home/deploy/.rvm/gems/ruby-1.9.2-p136/bin/whenever --write-crontab'" on lasource.ohlalaweb.com

Any suggestions will be welcome.

By the way, where are the capistrano logs?

Having added 'bundle exec' thanks to the Simone's suggestion, I managed to complete the cap deploy routine as it everything went well. The new problem however is that my crontab file is still empty of tasks and did not create my section with its 4 tasks.

Muntasim
  • 6,689
  • 3
  • 46
  • 69
allesklar
  • 9,506
  • 6
  • 36
  • 53

2 Answers2

10

If using Rails 3, remember to execute the command with bundle exec.

namespace :deploy do
  desc "Update the crontab file"
  task :update_crontab, :roles => :app, :except => { :no_release => true } do
    run "cd #{release_path} && bundle exec whenever --update-crontab #{application}"
  end
end
Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
  • Hi Simone. I followed your suggestion and progressed one step further. I edited my question to show the new error message i get now. – allesklar Feb 09 '11 at 22:14
  • After a few tweaks my cap deploy routine finishes successfully. It tells me that it's updating the crontab but nothing happens. crontab -e still shows an empty file. – allesklar Feb 09 '11 at 22:44
  • 2
    Add your schedule.rb file so that we can check the content. – Simone Carletti Feb 10 '11 at 08:19
  • Thank you for your effort Simone. I decided for now to give up on this. I just set up my cron tabs manually. They don't change much so it's ok. I'll revisit this issue later. I need to prioritize. Cheers – allesklar Feb 10 '11 at 16:37
  • I'm having similar problems yet no errors in the Capistrano output. Have you tried running `RAILS_ENV=production bundle exec whenever -w` from within the production environment on the command line? – nulltek Sep 22 '14 at 14:54
0

According to the whenever's README:

If a :path is not set it will default to the directory in which whenever was executed.

So you shouldn't have to cd in a folder. Also, have you tried using the other ways of calling a shell command? I'm using backticks and it is working in my env

namespace :deploy do
  desc "Update the crontab file"
  task update_crontab: :environment do
    `whenever -i cellar`
  end
end
mxg
  • 16
  • 2