如何解决“如果希望使用gem'daemons'到您的Gemfile中”,生产模式错误? [英] How to solve the "You need to add gem 'daemons' to your Gemfile if you wish to use it" error in production mode?
问题描述
我正在尝试正确使用Capistrano和RVM,以便将Ruby on Rails 3.2.2应用程序部署到运行Ubuntu 10.04 LTS的远程计算机上。 接缝我解决了与 Rvm相关的先前问题-Linux Ubuntu上的Capistrano集成。但是,在部署时,出现与DelayedJob gem有关的以下错误:
I am trying to properly use Capistrano and RVM in order to deploy my Ruby on Rails 3.2.2 application to the remote machine that is running Ubuntu 10.04 LTS. It seams that I solved my previous problem related to the "Rvm - Capistrano integration on Linux Ubuntu". However, on deploying I get the following error related to the DelayedJob gem:
...
* executing "cd /srv/www/<APP_NAME>/releases/20120314135318 && bundle install"
servers: ["<DOMAIN>"]
[<DOMAIN>] executing command
[<DOMAIN>] rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'ruby-1.9.3-p125' -c 'cd /srv/www/<APP_NAME>/releases/20120314135318 && bundle install' ** [out :: <DOMAIN>] Using rake (0.9.2.2)
** [out :: <DOMAIN>] Using builder (3.0.0)
...
** [out :: <DOMAIN>] Using daemons (1.1.8)
** [out :: <DOMAIN>] Using delayed_job (3.0.1)
** [out :: <DOMAIN>] Using delayed_job_active_record (0.3.2)
...
** [out :: <DOMAIN>] Your bundle is complete! It was installed into /srv/www/<APP_NAME>/shared/bundle
...
[<DOMAIN>] executing command
[<DOMAIN>] rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'ruby-1.9.3-p125' -c 'cd /srv/www/<APP_NAME>/current; RAILS_ENV=production script/delayed_job stop'
*** [err :: <DOMAIN>] /usr/local/rvm/gems/ruby-1.9.3-p125/gems/delayed_job-3.0.1/lib/delayed/command.rb:4:in `rescue in <top (required)>'
*** [err :: <DOMAIN>] :
*** [err :: <DOMAIN>] You need to add gem 'daemons' to your Gemfile if you wish to use it.
*** [err :: <DOMAIN>] (
*** [err :: <DOMAIN>] RuntimeError
*** [err :: <DOMAIN>] )
*** [err :: <DOMAIN>] from /usr/local/rvm/gems/ruby-1.9.3-p125/gems/delayed_job-3.0.1/lib/delayed/command.rb:1:in `<top (required)>'
*** [err :: <DOMAIN>] from /usr/local/rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `require'
*** [err :: <DOMAIN>] from /usr/local/rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `block in require'
*** [err :: <DOMAIN>] from /usr/local/rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:236:in `load_dependency'
*** [err :: <DOMAIN>] from /usr/local/rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `require'
*** [err :: <DOMAIN>] from script/delayed_job:4:in `<main>'
command finished in 7512ms
*** [deploy:update_code] rolling back
...
failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell 'ruby-1.9.3-p125' -c 'cd /srv/www/<APP_NAME>/releases && tar xzf /tmp/20120314140345.tar.gz && rm /tmp/20120314140345.tar.gz'" on <DOMAIN>
即使错误解释是如果您想使用它,则需要在其Gemfile中添加gem'daemons',我已经将 daemons
gem添加到了我的 Gemfile
(从上面的输出中,您甚至可以注意到我是正在使用守护程序(1.1.8)):
Even if the error explanation is "You need to add gem 'daemons' to your Gemfile if you wish to use it", I already added the daemons
gem to my Gemfile
(from the above output you can even note that I am "Using daemons (1.1.8)"):
...
gem 'delayed_job'
gem 'delayed_job_active_record'
gem 'daemons'
...
那么,问题出在哪里?我该如何解决?
在我的 deploy.rb
文件中,我有:
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require 'rvm/capistrano'
set :rvm_ruby_string, 'ruby-1.9.3-p125'
set :rvm_type, :user
require 'bundler/capistrano'
...
PS :终端窗口输出:
$ ruby -v
> ruby 1.9.3p125 (2012-02-16 revision 34643) [i686-linux]
$ which ruby
> /usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby
推荐答案
使用捆绑程序运行脚本/延迟作业:
捆绑执行脚本/延迟作业开始
Run script/delayed_job with bundler:
bundle exec script/delayed_job start
这篇关于如何解决“如果希望使用gem'daemons'到您的Gemfile中”,生产模式错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!