Question

When I'm trying to deploy with capistrano I get a error

/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)

Moreover, in output I have multiple instances of this:

** [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

What I found out is that this output comes from capture function, defined in 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

And thus function parse_manifest tries to parse this output of capture method instead of what it wants.

What's totally strange is that PATH string with /usr/games at the end.

Part of Gemfile:

gem 'capistrano'
gem 'rvm-capistrano'

Capfile:

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

deploy.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'

Any ideas?

Ruby 2.0.0, Rails 4, Capistrano 2.15.5. Server - ubuntu 12.04, JS executable - nodejs.

Was it helpful?

Solution

Solved it. Still dunno what really happens there in the deep of capture function, but editing deploy.rb helped. Here is my working config:

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_string)}"

=begin
# These sets somehow messed up everything. 
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;",
}
=end


#set :rvm_bin_path, "/usr/local/rvm/bin"
set :rvm_type, :system  # Copy the exact line. I really mean :system here*

set :scm, :none
set :repository, '.'
set :deploy_via, :copy

set :rails_env, 'production'


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' #loggin as root, so no sudo required
set :password, 'password'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top