Cron and bundle exec problem

I upgraded to rails 3.0.9, which introduced rake issues. I solved everything, except for the cron job issue.

This worked:

#!/bin/sh source /usr/local/rvm/scripts/rvm cd /home/p1r65759/apps/abbc/ /usr/local/bin/rake refresh_events RAILS_ENV=production 

But now I get this error: You have already activated rake 0.8.7, but your Gemfile requires rake 0.9.2. Consider using bundle exec. / home / p 1r65759 / apps / abbc / Rakefile: 4: in `` (See Complete trace by completing the task with --trace)

How do I change my script to use batch exec so that it uses the correct version of rake and works successfully? Thanks.

+6
source share
2 answers

If you use bundler for your application, you do not need to use "/ usr / local / bin / rake" as the path for the rake.

you can just use

  bundle exec rake 

so your new script will be

  #! / bin / sh
 source / usr / local / rvm / scripts / rvm 
 cd / home / p1r65759 / apps / abbc /
 bundle exec rake refresh_events RAILS_ENV = production

bundle exec will work because you are already in the project directory.

And don't forget to include a rake in your gemfile.

+9
source

instead

 /usr/local/bin/rake refresh_events RAILS_ENV=production 

you should use

 bundle exec rake refresh_events RAILS_ENV=production 

or better yet install your package with --binstubs:

 bundle install --binstubs --without development test 

then you will have a bit / rake:

 ./bin/rake refresh_events RAILS_ENV=production 
+4
source

Source: https://habr.com/ru/post/895259/


All Articles