Topic: Capistrano from Windows - possible SFTP issue

Hello all, thanks in advance for the comments. I've used Capistrano from Mac -> Linux, and Linux -> Linux with great success. However, I am trying to do a deployment from WinXp -> Linux, and am having some issues. First things first, I've validated that a Linux -> Linux deployment works with my target machine (both with and w/o SSH keys).

I'm not checking out from version-control, but doing a deploy via copy. It appears that SFTP is failing (though I've tried via SCP as well w/o success). Let's look at my error:

C:\DEV\rubyw\demo>cap deploy
  * executing `deploy'
  * executing `deploy:update'
 ** transaction: start
  * executing `deploy:update_code'
  * getting (via export) revision  to C:\DEV\rubyw\demo_build/20101102193344
    executing locally: xcopy C:\DEV\rubyw\demo "C:\DEV\rubyw\demo_build/2010110219
3344" /S/I/Y/Q/E
63 File(s) copied
    compressing C:\DEV\rubyw\demo_build/20101102193344 to C:\DEV\rubyw\demo_build/
20101102193344.zip
    executing locally: zip -qr 20101102193344.zip 20101102193344
    servers: ["jacks_prod_server"]
Password:
 ** sftp upload C:\DEV\rubyw\demo_build/20101102193344.zip -> /home/jack_bauer/railsapps/sample_app_deployed/tm
p/20101102193344.zip
*** [deploy:update_code] rolling back
  * executing "rm -rf /home/jack_bauer/railsapps/sample_app_deployed/releases/20101102193344; true"
    servers: ["jacks_prod_server"]
    [jacks_prod_server] executing command
    command finished
C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/transfer.rb:156:in `[]=': undefined me
thod `[]=' for nil:NilClass (NoMethodError)
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/transfer.rb:207:in `handl
e_error'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/transfer.rb:48:in `rescue
 in block in process!'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/transfer.rb:44:in `block
in process!'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/transfer.rb:43:in `loop'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/transfer.rb:43:in `proces
s!'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/transfer.rb:11:in `proces
s'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/actions/fil
e_transfer.rb:40:in `block in transfer'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/connections
.rb:172:in `block in execute_on_servers'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/connections
.rb:160:in `each'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/connections
.rb:160:in `each_slice'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/connections
.rb:160:in `execute_on_servers'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/actions/fil
e_transfer.rb:38:in `transfer'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/actions/fil
e_transfer.rb:26:in `upload'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/recipes/deploy/strategy/b
ase.rb:43:in `method_missing'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/recipes/deploy/strategy/c
opy.rb:104:in `deploy!'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/recipes/deploy.rb:210:in
`block (2 levels) in load'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/execution.r
b:139:in `instance_eval'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/execution.r
b:139:in `invoke_task_directly'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/callbacks.r
b:27:in `invoke_task_directly_with_callbacks'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/execution.r
b:89:in `execute_task'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/namespaces.
rb:186:in `method_missing'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/namespaces.
rb:104:in `block in task'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/recipes/deploy.rb:191:in
`block (3 levels) in load'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/execution.r
b:56:in `transaction'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/namespaces.
rb:186:in `method_missing'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/recipes/deploy.rb:190:in
`block (2 levels) in load'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/execution.r
b:139:in `instance_eval'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/execution.r
b:139:in `invoke_task_directly'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/callbacks.r
b:27:in `invoke_task_directly_with_callbacks'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/execution.r
b:89:in `execute_task'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/namespaces.
rb:186:in `method_missing'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/namespaces.
rb:104:in `block in task'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/recipes/deploy.rb:159:in
`block (2 levels) in load'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/execution.r
b:139:in `instance_eval'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/execution.r
b:139:in `invoke_task_directly'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/callbacks.r
b:27:in `invoke_task_directly_with_callbacks'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/execution.r
b:89:in `execute_task'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/configuration/execution.r
b:101:in `find_and_execute_task'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/cli/execute.rb:46:in `blo
ck in execute_requested_actions'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/cli/execute.rb:45:in `eac
h'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/cli/execute.rb:45:in `exe
cute_requested_actions'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/cli/help.rb:19:in `execut
e_requested_actions_with_help'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/cli/execute.rb:34:in `exe
cute!'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/lib/capistrano/cli/execute.rb:14:in `exe
cute'
        from C:/DEV/programs/Ruby192/lib/ruby/gems/1.9.1/gems/capistrano-2.5.19/bin/cap:4:in `<top (required)>'
        from C:/DEV/programs/Ruby192/bin/cap:19:in `load'
        from C:/DEV/programs/Ruby192/bin/cap:19:in `<main>'

C:\DEV\rubyw\demo>



and here is my deploy.rb

set :user, 'jack_bauer'   
set :project, 'demo'  
set :application, 'sample_app.com'  
 
set :scm, :none
set :repository, "C:\\DEV\\demo"
set :copy_dir, "C:\\DEV\\demo_build"
 
# deploy config
set :deploy_to, "/home/jack_bauer/railsapps/sample_app_deployed"
set :deploy_via, :copy
set :copy_strategy, :export
set :copy_compression, :zip

set :copy_remote_dir, "#{deploy_to}/tmp"

# roles (servers)
role :app, 'jacks_prod_server'
role :web, 'jacks_prod_server'

namespace :deploy do
  task :start do ; end
  task :stop do ; end
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "touch #{File.join(current_path,'tmp','restart.txt')}"
  end
end

default_run_options[:pty] = true  # Forgo errors when deploying from windows
set :chmod755, 'app config db lib public vendor script script/* public/disp*'
set :use_sudo, false

It's very possible that I don't have something installed on this windows machine that Capistrano requires. Any help is greatly appreciated.

Thanks!

Last edited by expectationgap (2010-11-02 15:54:28)

Re: Capistrano from Windows - possible SFTP issue

I use Capistrano on Windows but I am deploying from SCM. It works well, not sure how it works from a direct copy though.

Re: Capistrano from Windows - possible SFTP issue

jmesserer: are you executing your capistrano tasks on a "build" machine, or on the target deployment server?

Last edited by expectationgap (2010-11-02 17:18:32)

Re: Capistrano from Windows - possible SFTP issue

I initiate the task from my development server but the tasks are executed on the target deployment server.

Re: Capistrano from Windows - possible SFTP issue

Ah, that's a different kind of deployment. Unfortunately, we are deploying to multiple boxes - so that strategy won't work efficiently. Thanks though!