Capistrano +每当gem:无法部署时,“只要不是bundle的一部分。将它添加到Gemfile中。”

时间:2013-09-29 11:54:29

标签: ruby-on-rails ruby capistrano whenever whenever-capistrano

我试图将Whenever gem添加到我的Rails项目中,我将gem添加到Gemfile

gem "whenever", "~> 0.8.4"

并且安装没有任何问题。 然后我在生成的schedule.rb文件中添加了一个简单的任务:

 set :output, "/home/my_deploy_name/project_name/current/log/cron_log.log"

 every 2.minutes do
   command "/usr/bin/some_great_command"
   runner "MyModel.some_method"
   rake "some:great:rake:task"
   puts "It's working !!!"
 end

然后我在deploy.rb文件中添加了以下内容:

set :whenever_command, "bundle exec whenever"
require "whenever/capistrano"
namespace :deploy do
  desc "Update the crontab file"
  task :update_crontab, :roles => :db do
    run "cd #{latest_release} && whenever --update-crontab #{application}"
  end
end

我尝试设置latest_releasecurrent_pathrelease_path,但在所有情况下始终都是相同的输出:

*** [err :: IP] sh: 1:
*** [err :: IP] whenever: not found
*** [err :: IP]
...
*** [err :: 54.221.241.111] /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/rubygems_integration.rb:214:in `block in replace_gem'
*** [err :: IP] :
*** [err :: IP] whenever is not part of the bundle. Add it to Gemfile.
*** [err :: IP] (
*** [err :: IP] Gem::LoadError
*** [err :: IP] )
*** [err :: IP] from /home/my_deploy_name/project_name/shared/bundle/ruby/2.0.0/bin/whenever:22:in `<main>'

如何解决此问题? (我正在部署到Amazon EC2 - ubuntu)

由于

1 个答案:

答案 0 :(得分:1)

“每当”我遇到了这个问题......

开玩笑吧。实际上这与capistrano有关,而不是什么时候。您正在调用deploy.rb中的when命令而没有bundle上下文。

run "cd #{latest_release} && whenever --update-crontab #{application}"

试试这个:

run "cd #{latest_release} && bundle exec whenever --update-crontab #{application}"