1
votes

I've read this post Whenever errors and tried to implement the recommendations to no avail. I'm still receiving '/bin/bash: bundle: command not found' error. On Amazon EC2.

which ruby

/usr/local/bin/ruby

which bundler

/usr/local/bin/bundler

schedule.rb

env :PATH, ENV['PATH']
require File.expand_path('../application', __FILE__)
set :output, "log/cron_log.log"

every 1.minutes do
  rake "calculate:calculate"
end

crontab -e

          • /bin/bash -l -c 'cd /srv/www/myapp/releases/20141022032959 && RAILS_ENV=development bundle exec rake calculate:calculate --silent >> log/cron_log.log 2>&1'

tail -f log/cron_log.log

/bin/bash: bundle: command not found

When I copy the command out of crontab and run it directly, everything works fine (cd /srv/www/myapp/releases/20141022032959 && RAILS_ENV=development bundle exec rake calculate:calculate --silent >> log/cron_log.log 2>&1). It's the prepending of /bin/bash that's messing this up.

How do I get schedule.rb / whenever gem to recognize correct PATH.

3

3 Answers

17
votes

Forget about PATH settings in cron files. Setting the PATH does not work.

Set the path to bundle explicitly in your config/schedule.rb

set :bundle_command, "/usr/local/bin/bundle exec"

Edit: exec added so that task can run

2
votes

If none of the above solution works this did it for me without any additional setup

rvm cron setup

This will include all the right paths for gems so you do this on your machine and you are good to go.

1
votes

If using rbenv, the path is "/home/YOUR_USER/.rbenv/shims/bundle", so you shoud write at the top of schedule.rb..:

set :bundle_command, "/home/YOUR_USER/.rbenv/shims/bundle exec"