【问题标题】:cron and bundle exec problemcron 和 bundle exec 问题
【发布时间】:2011-10-29 02:16:39
【问题描述】:

我已经升级到引入了 rake 问题的 rails 3.0.9。除了 cron 作业的问题,我已经解决了所有问题。

这曾经有效:

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

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

如何修改我的脚本以使用 bundle exec 以便它使用正确版本的 rake 并成功运行? 谢谢。

【问题讨论】:

  • 有类似的问题,但没有 RVM。无论如何,也许您可​​以指定 rake 0.9.2 的路径或将系统 rake gem 更新为 0.9.2(取决于这是否是服务器上唯一的应用程序...)
  • 已修复,感谢 HostingRails.com 的技术支持。刚刚将最后一行更改为 bundle exec rake refresh_events RAILS_ENV=production。也不需要前面的路径。我不知道你能做到。
  • 添加它作为答案,然后接受它。对于后代和未来的谷歌员工:-)

标签: ruby-on-rails-3 cron bundler


【解决方案1】:

如果您在应用程序中使用捆绑程序,则不需要使用“/usr/local/bin/rake”作为 rake 的路径。

你可以使用

捆绑 exec rake

所以你的新脚本将是

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

bundle exec 可以工作,因为您已经在项目目录中。

别忘了在你的 Gemfile 中包含 rake。

【讨论】:

    【解决方案2】:

    而不是

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

    你应该使用

    bundle exec rake refresh_events RAILS_ENV=production
    

    或者更好的是使用 --binstubs 安装你的包:

    bundle install --binstubs --without development test
    

    那么你将拥有 bin/rake:

    ./bin/rake refresh_events RAILS_ENV=production
    

    【讨论】:

      猜你喜欢
      • 2014-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-22
      • 2012-02-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多