Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capistrano: run with options --dry-run #39

Closed
stamm opened this issue Oct 28, 2013 · 22 comments
Closed

Capistrano: run with options --dry-run #39

stamm opened this issue Oct 28, 2013 · 22 comments

Comments

@stamm
Copy link

@stamm stamm commented Oct 28, 2013

cap local deploy --dry-run --trace
** Invoke local (first_time)
** Execute local
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke deploy (first_time)
** Execute deploy
** Invoke deploy:starting (first_time)
** Execute deploy:starting
** Invoke deploy:check (first_time)
** Execute deploy:check
** Invoke git:check (first_time)
** Invoke git:wrapper (first_time)
** Execute git:wrapper
cap aborted!
undefined method `verbosity' for "/usr/bin/env #<StringIO:0x007ff7a9827118> /tmp/git-ssh.sh":String
/Users/stamm/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.1.0/lib/sshkit/formatters/pretty.rb:10:in `write'
/Users/stamm/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.1.0/lib/sshkit/backends/printer.rb:14:in `block in execute'
/Users/stamm/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.1.0/lib/sshkit/backends/printer.rb:13:in `tap'
/Users/stamm/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.1.0/lib/sshkit/backends/printer.rb:13:in `execute'
/Users/stamm/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-3.0.0/lib/capistrano/tasks/git.rake:11:in `block (3 levels) in <top (required)>'
/Users/stamm/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.1.0/lib/sshkit/backends/printer.rb:9:in `instance_exec'
/Users/stamm/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.1.0/lib/sshkit/backends/printer.rb:9:in `run'
/Users/stamm/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.1.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => git:check => git:wrapper

In https://github.com/leehambley/sshkit/blob/ffbce7622ae57bb960d4a75375f5afb18b9228b7/lib/sshkit/backends/printer.rb#L14

output << cmd.to_s

This line call SSHKit::Formatter::Pretty.write() with object String

If temporary comment this line
https://github.com/leehambley/sshkit/blob/ffbce7622ae57bb960d4a75375f5afb18b9228b7/lib/sshkit/formatters/pretty.rb#L10
I will get messages:

Output formatter doesn't know how to handle String

In 5 minutes I have change line to:

return if obj.respond_to?(:verbosity) && obj.verbosity < SSHKit.config.output_verbosity

And add more condition:

when ::String then original_output << obj + "\n"

It's look like what I want.

cap local deploy --dry-run
/usr/bin/env #<StringIO:0x007f92cb827368> /tmp/git-ssh.sh
/usr/bin/env chmod +x /tmp/git-ssh.sh
/usr/bin/env git ls-remote git@bitbucket.org:stamm/grape.git
/usr/bin/env mkdir -pv /var/www/shared /var/www/releases
/usr/bin/env mkdir -pv /var/www/shared/log /var/www/shared/tmp/pids /var/www/shared/tmp/cache /var/www/shared/tmp/sockets
/usr/bin/env mkdir -pv /var/www/shared/config
/usr/bin/env [ -f /var/www/shared/config/thin.yml ]
/usr/bin/env [ -f /var/www/repo/HEAD ]
 INFO The repository mirror is at /var/www/repo
/usr/bin/env if test ! -d /var/www/repo; then echo "Directory does not exist '/var/www/repo'" 1>&2; false; fi
/usr/bin/env git remote update
/usr/bin/env if test ! -d /var/www/repo; then echo "Directory does not exist '/var/www/repo'" 1>&2; false; fi
/usr/bin/env mkdir -p /var/www/releases/20131028002432
/usr/bin/env git archive master | tar -x -C /var/www/releases/20131028002432
/usr/bin/env mkdir -pv /var/www/releases/20131028002432/config
/usr/bin/env [ -L /var/www/releases/20131028002432/config/thin.yml ]
/usr/bin/env mkdir -pv /var/www/releases/20131028002432 /var/www/releases/20131028002432/tmp /var/www/releases/20131028002432/tmp /var/www/releases/20131028002432/tmp
/usr/bin/env [ -L /var/www/releases/20131028002432/log ]
/usr/bin/env [ -L /var/www/releases/20131028002432/tmp/pids ]
/usr/bin/env [ -L /var/www/releases/20131028002432/tmp/cache ]
/usr/bin/env [ -L /var/www/releases/20131028002432/tmp/sockets ]
/usr/bin/env if test ! -d /var/www/releases/20131028002432; then echo "Directory does not exist '/var/www/releases/20131028002432'" 1>&2; false; fi
/usr/bin/env bundle --gemfile /var/www/releases/20131028002432/Gemfile --path /var/www/shared/bundle --deployment --quiet --binstubs /var/www/shared/bin --without development test
/usr/bin/env rm -rf /var/www/current
/usr/bin/env ln -s /var/www/releases/20131028002432 /var/www/current
/usr/bin/env if test ! -d /var/www/releases/20131028002432; then echo "Directory does not exist '/var/www/releases/20131028002432'" 1>&2; false; fi
/usr/bin/env /var/www/shared/bin/thin restart -C /var/www/releases/20131028002432/config/thin.yml
/usr/bin/env ls -x /var/www/releases
/usr/bin/env if test ! -d /var/www/releases; then echo "Directory does not exist '/var/www/releases'" 1>&2; false; fi
/usr/bin/env echo "Branch master deployed as release 20131028002432 by stamm; " >> /var/www/revisions.log

I knew that is bad idea.
What you think about this problem?

@miry
Copy link
Contributor

@miry miry commented Oct 28, 2013

Now the option --dry-run is not working. for me too.

@Soliah
Copy link

@Soliah Soliah commented Oct 29, 2013

Downgrading to 1.0.0 works for me. I noticed that Rubygems has 1.1.0, but the repo hasn't been updated on master?

@rosic
Copy link

@rosic rosic commented Oct 30, 2013

I think, it would work nicely if the Printer didn't call to_s on the command and just shovel the whole command object into the output (which is the Pretty formatter expecting the command). The other formatter works well with Command as well (or simply don't care)

@leehambley
Copy link
Member

@leehambley leehambley commented Oct 30, 2013

I may have changed & broken that. I can confirm the log formatters expect
objects on Command and LogMessage (?) classes. Any thing contrary is
incorrect
On 30 Oct 2013 16:21, "Marek Rosa" notifications@github.com wrote:

I think, it would work nicely if the Printer didn't call to_s on the
command and just shovel the whole command object into the output (which is
the Pretty formatter expecting the command). The other formatter works
well with Command as well (or simply don't care)


Reply to this email directly or view it on GitHubhttps://github.com//issues/39#issuecomment-27398471
.

@deivid-rodriguez
Copy link

@deivid-rodriguez deivid-rodriguez commented Nov 5, 2013

Downgrading to 1.0.0 works for me. I noticed that Rubygems has 1.1.0, but the repo hasn't been updated on master?

Yep, it works!

@reicheltd
Copy link

@reicheltd reicheltd commented Nov 18, 2013

same issue here. using rbenv 2.0.0p247

@jrissler
Copy link

@jrissler jrissler commented Nov 21, 2013

@reicheltd confirmed w rbenv 2.0.0-p247

@laertiades
Copy link

@laertiades laertiades commented Nov 21, 2013

adding
gem 'sshkit', '~> 1.0.0'
before capistrano fixed issue for me

@sanichi
Copy link

@sanichi sanichi commented Nov 22, 2013

Version 1.2.0 has just been released to rubygems.org, but this issue is still present.

@leehambley
Copy link
Member

@leehambley leehambley commented Nov 22, 2013

Yes, @sanichi that's why the issue is still open… ?

@stamm
Copy link
Author

@stamm stamm commented Nov 22, 2013

@leehambley same error on version 1.2.0

cap local deploy --dry-run --trace
** Invoke local (first_time)
** Execute local
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke deploy (first_time)
** Execute deploy
** Invoke deploy:starting (first_time)
** Execute deploy:starting
** Invoke deploy:check (first_time)
** Execute deploy:check
** Invoke git:check (first_time)
** Invoke git:wrapper (first_time)
** Execute git:wrapper
cap aborted!
undefined method `verbosity' for "/usr/bin/env mkdir -p /tmp/my_app_name/\n":String
/Users/stamm/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.2.0/lib/sshkit/formatters/pretty.rb:10:in `write'
/Users/stamm/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.2.0/lib/sshkit/backends/printer.rb:14:in `block in execute'
/Users/stamm/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.2.0/lib/sshkit/backends/printer.rb:13:in `tap'
/Users/stamm/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.2.0/lib/sshkit/backends/printer.rb:13:in `execute'
/Users/stamm/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/capistrano-3.0.1/lib/capistrano/tasks/git.rake:13:in `block (3 levels) in <top (required)>'
/Users/stamm/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.2.0/lib/sshkit/backends/printer.rb:9:in `instance_exec'
/Users/stamm/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.2.0/lib/sshkit/backends/printer.rb:9:in `run'
/Users/stamm/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/sshkit-1.2.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => git:check => git:wrapper
@hab278
Copy link
Contributor

@hab278 hab278 commented Dec 11, 2013

@nikita-v has a solution #58 but I guess the commit message wasn't clear, and I don't think any tests were included.

The problem is with printer line 14:

  def execute(*args)
    command(*args).tap do |cmd|
      output << sprintf("%s\n", cmd) # Offending line, sprintf returns String, output<< expects Command
    end
  end

A quick and dirty solution is:

  def execute(*args)
    command(*args).tap do |cmd|
      output << cmd # cmd is a Command and has the `verbosity` method
    end
  end

I guess at one point in time output<< accepted Strings

@the-teacher
Copy link

@the-teacher the-teacher commented Jan 4, 2014

+1

$ cap production deploy --dry-run
cap aborted!
undefined method `verbosity' for "mkdir -p /tmp/project.com/\n":String
@leehambley
Copy link
Member

@leehambley leehambley commented Jan 4, 2014

What is the +1 supposed to say?

#58 was merged, and has been released. If that was not a solution, then please be more desciptive and see the contributing guidelines at https://github.com/capistrano/capistrano/blob/master/CONTRIBUTING.md

@the-teacher
Copy link

@the-teacher the-teacher commented Jan 5, 2014

@leehambley, hello! I just have same problem. I don't know why - but I have it.

GEM
  remote: http://rubygems.org/
  specs:
    capistrano (3.0.1)
      i18n
      rake (>= 10.0.0)
      sshkit (>= 0.0.23)
    capistrano-bundler (1.1.1)
      capistrano (~> 3.0)
      sshkit (>= 1.2.0)
    capistrano-rails (1.1.0)
      capistrano (>= 3.0.0)
      capistrano-bundler (>= 1.0.0)
    capistrano-rvm (0.0.3)
      capistrano
    i18n (0.6.9)
    net-scp (1.1.2)
      net-ssh (>= 2.6.5)
    net-ssh (2.7.0)
    rake (10.1.1)
    settingslogic (2.0.9)
    sshkit (1.3.0)
      net-scp (>= 1.1.2)
      net-ssh
      term-ansicolor
    term-ansicolor (1.2.2)
      tins (~> 0.8)
    tins (0.13.1)

PLATFORMS
  ruby

DEPENDENCIES
  capistrano (~> 3.0.1)
  capistrano-bundler
  capistrano-rails (~> 1.1)
  capistrano-rvm
  settingslogic
@mengqing
Copy link

@mengqing mengqing commented Jan 6, 2014

@the-teacher The gem hasn't been updated on Rubygem.org yet. Just use the repository

gem 'sshkit', '~> 1.3', github: 'capistrano/sshkit'
@leehambley
Copy link
Member

@leehambley leehambley commented Jan 6, 2014

It should be released??

Sent from my Nexus 4.
On 6 Jan 2014 06:10, "mengqing" notifications@github.com wrote:

@the-teacher https://github.com/the-teacher The gem hasn't been updated
on Rubygem.org yet. Just use the repository

gem 'sshkit', '~> 1.3', github: 'capistrano/sshkit'


Reply to this email directly or view it on GitHubhttps://github.com//issues/39#issuecomment-31627926
.

@leehambley
Copy link
Member

@leehambley leehambley commented Jan 6, 2014

http://rubygems.org/gems/sshkit/versions/1.3.0

Sent from my Nexus 4.
On 6 Jan 2014 06:52, "Lee Hambley" lee.hambley@gmail.com wrote:

It should be released??

Sent from my Nexus 4.
On 6 Jan 2014 06:10, "mengqing" notifications@github.com wrote:

@the-teacher https://github.com/the-teacher The gem hasn't been
updated on Rubygem.org yet. Just use the repository

gem 'sshkit', '~> 1.3', github: 'capistrano/sshkit'


Reply to this email directly or view it on GitHubhttps://github.com//issues/39#issuecomment-31627926
.

@mengqing
Copy link

@mengqing mengqing commented Jan 6, 2014

Not with the #58 merge which @the-teacher is still having problems with

@bluebird-communication
Copy link

@bluebird-communication bluebird-communication commented Feb 1, 2014

This is still an issue.
Even with this in my Gemfile :
gem 'sshkit', '> 1.3', github: 'capistrano/sshkit'
The latest patch 'maybe' solves the "undefined method 'verbosity'" error message, but still create an issue with Capistrano : you can not anymore call a task from within anoth task.
The only workaround is to use
gem 'capistrano', '
> 3.0.1'
gem 'sshkit', '~> 1.0.0'

@hab278
Copy link
Contributor

@hab278 hab278 commented Feb 3, 2014

@bluebird-communication The verbosity error you're getting was fixed, but for some reason is not reflected in RubyGems. Even after the fix, your error will remain. see capistrano/capistrano#912 for details. I'm not sure if the issue should be raised in sshkit, Capistrano, or both since its a confusion in method names.

@amstec
Copy link

@amstec amstec commented Apr 28, 2017

Hey there. Coming background to this, I was pulled into a few other things. I want to push this change to production for now till I can spend some time on the category changes you suggested. I tried a dry-run and am seeing a few issues. Since I am not too familiar with cap was hoping you might have some insight. First I assume we can run "cap production deploy" from our local repositories, is that correct?

Here is the output from the dry-run:

$ cap -nt production deploy
cap aborted!
LoadError: cannot load such file -- capistrano/rvm
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Users/ams/Documents/Git Repositories/weddingbellinvitations/Capfile:17:in `<top (required)>'
/Library/Ruby/Gems/2.0.0/gems/rake-12.0.0/lib/rake/rake_module.rb:28:in `load'
/Library/Ruby/Gems/2.0.0/gems/rake-12.0.0/lib/rake/rake_module.rb:28:in `load_rakefile'
/Library/Ruby/Gems/2.0.0/gems/rake-12.0.0/lib/rake/application.rb:687:in `raw_load_rakefile'
/Library/Ruby/Gems/2.0.0/gems/rake-12.0.0/lib/rake/application.rb:96:in `block in load_rakefile'
/Library/Ruby/Gems/2.0.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
/Library/Ruby/Gems/2.0.0/gems/rake-12.0.0/lib/rake/application.rb:95:in `load_rakefile'
/Library/Ruby/Gems/2.0.0/gems/rake-12.0.0/lib/rake/application.rb:79:in `block in run'
/Library/Ruby/Gems/2.0.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
/Library/Ruby/Gems/2.0.0/gems/rake-12.0.0/lib/rake/application.rb:77:in `run'
/Library/Ruby/Gems/2.0.0/gems/capistrano-3.8.0/lib/capistrano/application.rb:14:in `run'
/Library/Ruby/Gems/2.0.0/gems/capistrano-3.8.0/bin/cap:3:in `<top (required)>'
/usr/bin/cap:23:in `load'
/usr/bin/cap:23:in `<main>'

Thanks!
ams

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet