This is the code i have written in schedule.rb
every 2.minutes do
rake "task_overdue:overdue"
end
But after 2 minutes i am getting error /bin/bash: bundle: command not found in cron.log file
Using Rails4 with latest whenever gem.
Tried to fix it but giving the same error.
I have the same issue. The crontab listed command can be run manually just fine and shows up in the log file.
Looks like it was an old error:
https://groups.google.com/forum/#!msg/whenever-gem/yRLt3f2jrfU/Exu3xfCo8DAJ
Setting the PATH seems to do the trick with:
env :PATH, ENV['PATH']
This seems like a reasonable default that whenever should include in the crontab file automatically.
Also try following 2 line in schedule.rb
env :PATH, ENV['PATH']
env :GEM_PATH, ENV['GEM_PATH']
I could not get any of them to work for the life of me.
My gem env:
RubyGems Environment:
My $PATH
/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
And my bundle show --paths is listing bundler as being in:
/usr/local/bundle/gems/bundler-1.10.5
My crontab file:
`PATH=/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
GEM_PATH=/usr/local/bundle:/root/.gem/ruby/2.2.0:/usr/local/lib/ruby/gems/2.2.0
0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58 * * * * /bin/bash -l -c 'cd /app && RAILS_ENV=production bundle exec rake test_task --silent >> log/cron_log.log 2>> log/cron_error_log.log'
End Whenever generated tasks for: /app/config/schedule.rb
I'm using a docker container from the rails:4.2.3 image with my app and cron installed. I'm not using rbenv or rvm.
Any ideas?
I have similar problem, I use
env :PATH, ENV['PATH']
env :GEM_PATH, ENV['GEM_PATH']
env :GEM_HOME, ENV['GEM_HOME']
and nothing.
in my .bashrc I add
source "$HOME/.rvm/scripts/rvm"
also nothing. But when I login to my server and run the task I do not have problems
I solve my problem with this code
rvm cron setup
And delete all env set
env :PATH, ENV['PATH']
env :GEM_PATH, ENV['GEM_PATH']
env :GEM_HOME, ENV['GEM_HOME']
env :PATH, ENV['PATH'] solved my issue.
env :GEM_PATH, ENV['GEM_PATH'] creates more error in my case:
/home/ubuntu/.rbenv/versions/2.2.5/lib/ruby/2.2.0/rubygems/dependency.rb:315:into_specs': Could not find 'bundler' (>= 0) among 6 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=', execute gem env for more information
from /home/ubuntu/.rbenv/versions/2.2.5/lib/ruby/2.2.0/rubygems/dependency.rb:324:in to_spec'
from /home/ubuntu/.rbenv/versions/2.2.5/lib/ruby/2.2.0/rubygems/core_ext/kernel_gem.rb:64:ingem'
from /home/ubuntu/.rbenv/versions/2.2.5/bin/bundle:22:in <main>'
[comment is tangential to problema at hand, but may be useful for someone stumbling upon this]
I second yjchieng's observation. I would add that askrynnikov's comment was also needed for me to get a whenever taks to run properly, as rbenv was not being found as well.
env :PATH, ENV['PATH'] at the top of my schedule.rb also solved it. I tried many other things. Using rbenv, capistrano, rails 5, and whenever gem.
@austinarchibald's comment worked for me, finally. There should really be a mention of this in the readme for RBENV users.
Most helpful comment
env :PATH, ENV['PATH']at the top of myschedule.rbalso solved it. I tried many other things. Using rbenv, capistrano, rails 5, and whenever gem.