Hi There,

I am attempted to have Capistrano tasks only display the commands instead 
of executing them. I did this by basically using a function which 
determines if the command needs to be executed or printed based on a 
'debug' flag passed as an argument which would be accessed as a environment 
variable,  however I encountered some exceptions:

What I've done:

def execute_as cmd

    if $debug.eql? 'true'
        puts cmd
    else
        execute "#{cmd}"
    end


The above works fine for all except for the following scenario:

# fails for any test command
if test(" [ ! -d /usr/backup ] ")
                    puts "+ Creating backup point /usr/backup.."
                    execute_as "sudo mkdir /usr/backup"
                    puts "#{$checkmark} Created /usr/backup"
                end


The exception below is:
1. Only generated when it encounters the first test command.
2. Does not terminate. Prints all command successfully until the end.


DEBUG[ba34641c] Command: [ ! -d /usr/backup ]
Exception `Net::SSH::Exception' at 
/opt/ruby/ruby-2.0.0-p451/usr/lib64/ruby/gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/transport/algorithms.rb:329
 
- could not settle on language_client algorithm
Exception `Net::SSH::Exception' at 
/opt/ruby/ruby-2.0.0-p451/usr/lib64/ruby/gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/transport/algorithms.rb:329
 
- could not settle on language_server algorithm
Exception `Net::SSH::Authentication::DisallowedMethod' at /opt/ruby/ruby-2.0
.0-p451/usr/lib64/ruby/gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/
authentication/methods/none.rb:23 - Net::SSH::Authentication::
DisallowedMethod
Exception `TypeError' at 
/opt/ruby/ruby-2.0.0-p451/usr/lib64/ruby/gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/authentication/agent/socket.rb:65
 
- no implicit conversion of nil into String
Exception `Net::SSH::Authentication::AgentNotAvailable' at 
/opt/ruby/ruby-2.0.0-p451/usr/lib64/ruby/gems/2.0.0/gems/net-ssh-2.9.1/lib/net/ssh/authentication/agent/socket.rb:68
 
- no implicit conversion of nil into String


I can SSH into the remote server successfully and if the debug option is 
off, no exceptions are generated.

A closer look led me to change the environment variable name (instead of 
using 'debug') which solved the problem.

I was hoping someone could explain this behavior? 
Thanks.


Versions:

   - Ruby 1.8.7
   - Capistrano 3


-- 
You received this message because you are subscribed to the Google Groups 
"Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to capistrano+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/capistrano/4e54d2e7-e3d7-4c0c-84bb-5e6f5d668783%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to