ruby on rails - Whenever gem for Cron job uses incorrect outdated version of bundler -
i set cron job in schedule.rb executes custom rake file. here schedule.rb:
set :environment , :development every 2.minutes rake "runpy" , :output => {:error => "/home/aditya9509/desktop/rubystack-2.0.0-33/projects/myapp/log/error.log" , :standard => "/home/aditya9509/desktop/rubystack-2.0.0-33/projects/myapp/log/cron.log"} end
note runpy custom rake file , works fine when ran terminal using command:
rake runpy
i have set standard output cron.log , error output error.log when running cron job, there no error printed in error.log following in cron .log:
in gemfile: rails (= 4.2.4) depends on bundler (< 2.0, >= 1.3.0) current bundler version: bundler (1.0.15)
so checked current bundler version using command
bundler --version
which outputs
bundler version 1.11.2
further, thought check list of available bundlers can uninstall 1.0.15 version used cron automatically uses 1.11.2 version. ran following command:
gem list | grep "bundler"
to surprise, 1.0.15 version being used cron not installed on system. here output of above command:
bundler (1.11.2, 1.3.6) hoe-bundler (1.2.0)
do know going on? not sure information relevant let me know, shall update question accordingly. using whenever gem set cron job.
cron doesn't run in interactive shell , therefoe doesn't load .bashrc. if you're using rvm or rbenv or similar, it's cron using system ruby, instead of latest ruby you've installed yourself.
to test this, try running which ruby
or ruby -v
cron. expect?
if not, try using shebang @ top of bin/rails
file coerce rails using proper ruby version. instance if you're using ruby 2.2.4:
at top of bin/rails
#!/users/<username>/.rvm/rubies/ruby-2.2.4/bin/ruby
obviously, substitute whatever path you're using ruby.
Comments
Post a Comment