cron和bundle exec问题

Bre*_*ett 6 cron bundler ruby-on-rails-3

我已经升级到rails 3.0.9,它引入了rake问题.除了cron作业的问题之外,我已经解决了这个问题.

这曾经工作:

#!/bin/sh
source /usr/local/rvm/scripts/rvm 
cd /home/p1r65759/apps/abbc/
/usr/local/bin/rake refresh_events RAILS_ENV=production
Run Code Online (Sandbox Code Playgroud)

但是现在我收到了这个错误:你已经激活了rake 0.8.7,但是你的Gemfile需要rake 0.9.2.考虑使用bundle exec./ home/p1r65759/apps/abbc/Rakefile:4:in`'(通过使用--trace运行任务查看完整跟踪)

如何修改我的脚本以使用bundle exec,这样它将使用正确版本的rake并成功运行?谢谢.

aru*_*agw 9

如果您正在为您的应用程序使用bundler,那么您不需要使用"/ usr/local/bin/rake"作为rake的路径.

你可以使用

bundle exec rake

所以你的新剧本将是

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

bundle exec将起作用,因为您已经在项目目录中.

并且不要忘记在你的Gemfile中加入rake.