当我尝试使用 capistrano 进行部署时,出现错误
/home/username/.rvm/gems/ruby-2.0.0-p0@dvr/gems/capistrano-2.15.5/lib/capistrano/recipes/deploy/assets.rb:28:in `parse_manifest': undefined method `to_a' for #<String:0x9fa62d0> (NoMethodError)
此外,在输出中,我有多个这样的实例:
** [out :: *IP_HERE*] SHELL=/bin/bash
** [out :: *IP_HERE*] SSH_CLIENT=*IP_HERE* 53366 22
** [out :: *IP_HERE*] USER=root
** [out :: *IP_HERE*] MAIL=/var/mail/root
** [out :: *IP_HERE*] PATH=/usr/local/rvm/gems/ruby-2.0.0-p247/bin:/usr/local/rvm/gems/ruby-2.0.0-p247@global/bin:/usr/local/rvm/rubies/ruby-2.0.0-p247/bin:/home/rails/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
** [out :: *IP_HERE*] PWD=/root
** [out :: *IP_HERE*] LANG=en_US.UTF-8
** [out :: *IP_HERE*] SHLVL=1
** [out :: *IP_HERE*] HOME=/root
** [out :: *IP_HERE*] LANGUAGE=en_US:en
** [out :: *IP_HERE*] LOGNAME=root
** [out :: *IP_HERE*] SSH_CONNECTION=*IP_HERE* 53366 *IP_HERE* 22
** [out :: *IP_HERE*] _=/usr/bin/env
** [out :: *IP_HERE*] RUBY_VERSION=ruby-2.0.0-p247
** [out :: *IP_HERE*] GEM_HOME=/usr/local/rvm/gems/ruby-2.0.0-p247:/usr/local/rvm/gems/ruby-2.0.0-p247@global
** [out :: *IP_HERE*] BUNDLE_PATH=/usr/local/rvm/gems/ruby-2.0.0-p247
我发现这个输出来自capture
gem ( path_to_cap_gem/configuration/actions/inspect.rb
) 中定义的函数:
def capture(command, options={})
output = ""
invoke_command(command, options.merge(:once => true, :eof => !command.include?(sudo))) do |ch, stream, data|
case stream
when :out then output << data
when :err then warn "[err :: #{ch[:server]}] #{data}"
end
end
output
end
因此函数 parse_manifest 试图解析capture
方法的这个输出而不是它想要的。
完全奇怪的是最后的PATH
字符串/usr/games
。
Gemfile 的一部分:
gem 'capistrano'
gem 'rvm-capistrano'
帽文件:
load 'deploy'
# Uncomment if you are using Rails' asset pipeline
load 'deploy/assets'
load 'config/deploy' # remove this line to skip loading any of the default tasks
部署.rb:
require 'bundler/capistrano'
require 'rvm/capistrano'
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
set :application, 'dvr_rails'
set :rvm_ruby, "ruby-2.0.0-p247"
set :rvm_ruby_string, 'ruby-2.0.0-p247@dvr'
set :rvm_gem_home, "/usr/local/rvm/gems/#{fetch(:rvm_ruby)}"
set :rvm_ruby_path, "/usr/local/rvm/rubies/#{fetch(:rvm_ruby)}"
set :default_environment, {
'RUBY_VERSION' => fetch(:rvm_ruby),
'GEM_HOME' => "#{fetch(:rvm_gem_home)}:#{fetch(:rvm_gem_home)}@global",
'BUNDLE_PATH' => fetch(:rvm_gem_home),
'PATH' => "#{fetch(:rvm_gem_home)}/bin:#{fetch(:rvm_gem_home)}@global/bin:#{fetch(:rvm_ruby_path)}/bin:/home/rails/.rvm/bin:$PATH;",
}
set :rvm_type, :system # Copy the exact line. I really mean :system here*
set :scm, :none
set :repository, '.'
set :deploy_via, :copy
server 'IP_HERE', :app, :web, :db, :primary => true
#If you are using Passenger mod_rails uncomment this:
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end
end
set :deploy_to, '/var/sites/dvr_rails'
set :user, 'root'
set :use_sudo, 'true'
set :password, 'password'
有任何想法吗?
Ruby 2.0.0、Rails 4、Capistrano 2.15.5。服务器 - ubuntu 12.04,JS 可执行文件 - nodejs。