Repository: capistrano/capistrano

Issue #168: Capture not working
Created: 2012-02-23T20:25:32Z
I have a simple task (in a rails project, rails 3.2.1, ruby 1.9.3-p125, rvm) that uses the capture method to see what has changed in git between the last deployment and now:
namespace :git do
  desc 'Get a diff between the latest revision on the server and HEAD'
  task :diff, :roles => :app do
    revision = capture("cat #{current_path}/REVISION")
    command = "git diff #{revision.strip} HEAD | $EDITOR -a"
    puts %{  * executing "#{command}"}
    system command
  end
end
Running the command produces the following stacktrace:
my_project$ cap staging git:diff
  * executing `staging'
  * executing `git:diff'
~/.rvm/gems/ruby-1.9.3-p125@my_project/gems/activesupport-3.2.1/lib/active_support/core_ext/kernel/reporting.rb:75:in `eval': (eval):1: syntax error, unexpected tREGEXP_BEG, expecting keyword_do or '{' or '(' (SyntaxError)
...pp.com/current/REVISION = CAT /VAR/WWW/APPS/MY.APP.C...
...                               ^
(eval):1: unknown regexp options - WWW
    from ~/.rvm/gems/ruby-1.9.3-p125@my_project/gems/activesupport-3.2.1/lib/active_support/core_ext/kernel/reporting.rb:75:in `ensure in capture'
    from ~/.rvm/gems/ruby-1.9.3-p125@my_project/gems/activesupport-3.2.1/lib/active_support/core_ext/kernel/reporting.rb:75:in `capture'
    from config/deploy/tasks.rb:168:in `block (2 levels) in load'
    from ~/.rvm/gems/ruby-1.9.3-p125@my_project/gems/capistrano-2.11.2/lib/capistrano/configuration/execution.rb:139:in `instance_eval'
    from ~/.rvm/gems/ruby-1.9.3-p125@my_project/gems/capistrano-2.11.2/lib/capistrano/configuration/execution.rb:139:in `invoke_task_directly'
    from ~/.rvm/gems/ruby-1.9.3-p125@my_project/gems/capistrano-2.11.2/lib/capistrano/configuration/callbacks.rb:25:in `invoke_task_directly_with_callbacks'
    from ~/.rvm/gems/ruby-1.9.3-p125@my_project/gems/capistrano-2.11.2/lib/capistrano/configuration/execution.rb:89:in `execute_task'
    from ~/.rvm/gems/ruby-1.9.3-p125@my_project/gems/capistrano-2.11.2/lib/capistrano/configuration/execution.rb:101:in `find_and_execute_task'
    from ~/.rvm/gems/ruby-1.9.3-p125@my_project/gems/capistrano-2.11.2/lib/capistrano/cli/execute.rb:46:in `block in execute_requested_actions'
    from ~/.rvm/gems/ruby-1.9.3-p125@my_project/gems/capistrano-2.11.2/lib/capistrano/cli/execute.rb:45:in `each'
    from ~/.rvm/gems/ruby-1.9.3-p125@my_project/gems/capistrano-2.11.2/lib/capistrano/cli/execute.rb:45:in `execute_requested_actions'
    from ~/.rvm/gems/ruby-1.9.3-p125@my_project/gems/capistrano-2.11.2/lib/capistrano/cli/help.rb:19:in `execute_requested_actions_with_help'
    from ~/.rvm/gems/ruby-1.9.3-p125@my_project/gems/capistrano-2.11.2/lib/capistrano/cli/execute.rb:34:in `execute!'
    from ~/.rvm/gems/ruby-1.9.3-p125@my_project/gems/capistrano-2.11.2/lib/capistrano/cli/execute.rb:14:in `execute'
    from ~/.rvm/gems/ruby-1.9.3-p125@my_project/gems/capistrano-2.11.2/bin/cap:4:in `<top (required)>'
    from ~/.rvm/gems/ruby-1.9.3-p125@my_project/bin/cap:19:in `load'
    from ~/.rvm/gems/ruby-1.9.3-p125@my_project/bin/cap:19:in `<main>'

It looks like the method missing for Capistrano::Configuration::Namespaces::Namespace is not being called because capture is defined on Kernel via activesupport

Duplicate issue #170: ActiveSupport 3.1.3 breaks `capture`
Created: 2012-02-27T10:54:53Z
Using cap deploy:cleanup while requiring active_support or rails it breaks:
executing `deploy:cleanup'
/Users/tvd/.rvm/gems/ruby-1.9.3-p0@alchemy-2.1/gems/activesupport-3.1.3/lib/active_support/core_ext/kernel/reporting.rb:75:in `eval': (eval):1: syntax error, unexpected tREGEXP_BEG, expecting keyword_do or '{' or '(' (SyntaxError)
$ls -xt /var/www/web0/html/alchemy2/re...
         ^
(eval):1: unknown regexp options - www
(eval):1: syntax error, unexpected tUMINUS, expecting keyword_do or '{' or '('
...0/html/alchemy2/releases = LS -XT /VAR/WWW/WEB0/HTML/ALCHEMY...
...                               ^
(eval):1: unknown regexp options - WWW
    from /Users/tvd/.rvm/gems/ruby-1.9.3-p0@alchemy-2.1/gems/activesupport-3.1.3/lib/active_support/core_ext/kernel/reporting.rb:75:in `ensure in capture'
    from /Users/tvd/.rvm/gems/ruby-1.9.3-p0@alchemy-2.1/gems/activesupport-3.1.3/lib/active_support/core_ext/kernel/reporting.rb:75:in `capture'
    from /Users/tvd/.rvm/gems/ruby-1.9.3-p0@alchemy-2.1/gems/capistrano-2.11.2/lib/capistrano/recipes/deploy.rb:427:in `block (2 levels) in load'
    from /Users/tvd/.rvm/gems/ruby-1.9.3-p0@alchemy-2.1/gems/capistrano-2.11.2/lib/capistrano/configuration/execution.rb:139:in `instance_eval'
    from /Users/tvd/.rvm/gems/ruby-1.9.3-p0@alchemy-2.1/gems/capistrano-2.11.2/lib/capistrano/configuration/execution.rb:139:in `invoke_task_directly'
    from /Users/tvd/.rvm/gems/ruby-1.9.3-p0@alchemy-2.1/gems/capistrano-2.11.2/lib/capistrano/configuration/callbacks.rb:25:in `invoke_task_directly_with_callbacks'
    from /Users/tvd/.rvm/gems/ruby-1.9.3-p0@alchemy-2.1/gems/capistrano-2.11.2/lib/capistrano/configuration/execution.rb:89:in `execute_task'
    from /Users/tvd/.rvm/gems/ruby-1.9.3-p0@alchemy-2.1/gems/capistrano-2.11.2/lib/capistrano/configuration/execution.rb:101:in `find_and_execute_task'
    from /Users/tvd/.rvm/gems/ruby-1.9.3-p0@alchemy-2.1/gems/capistrano-2.11.2/lib/capistrano/callback.rb:38:in `call'
    from /Users/tvd/.rvm/gems/ruby-1.9.3-p0@alchemy-2.1/gems/capistrano-2.11.2/lib/capistrano/configuration/callbacks.rb:123:in `block in trigger'
    from /Users/tvd/.rvm/gems/ruby-1.9.3-p0@alchemy-2.1/gems/capistrano-2.11.2/lib/capistrano/configuration/callbacks.rb:123:in `each'
    from /Users/tvd/.rvm/gems/ruby-1.9.3-p0@alchemy-2.1/gems/capistrano-2.11.2/lib/capistrano/configuration/callbacks.rb:123:in `trigger'
    from /Users/tvd/.rvm/gems/ruby-1.9.3-p0@alchemy-2.1/gems/capistrano-2.11.2/lib/capistrano/configuration/callbacks.rb:27:in `invoke_task_directly_with_callbacks'
    from /Users/tvd/.rvm/gems/ruby-1.9.3-p0@alchemy-2.1/gems/capistrano-2.11.2/lib/capistrano/configuration/execution.rb:89:in `execute_task'
    from /Users/tvd/.rvm/gems/ruby-1.9.3-p0@alchemy-2.1/gems/capistrano-2.11.2/lib/capistrano/configuration/execution.rb:101:in `find_and_execute_task'
    from /Users/tvd/.rvm/gems/ruby-1.9.3-p0@alchemy-2.1/gems/capistrano-2.11.2/lib/capistrano/cli/execute.rb:46:in `block in execute_requested_actions'
    from /Users/tvd/.rvm/gems/ruby-1.9.3-p0@alchemy-2.1/gems/capistrano-2.11.2/lib/capistrano/cli/execute.rb:45:in `each'
    from /Users/tvd/.rvm/gems/ruby-1.9.3-p0@alchemy-2.1/gems/capistrano-2.11.2/lib/capistrano/cli/execute.rb:45:in `execute_requested_actions'
    from /Users/tvd/.rvm/gems/ruby-1.9.3-p0@alchemy-2.1/gems/capistrano-2.11.2/lib/capistrano/cli/help.rb:19:in `execute_requested_actions_with_help'
    from /Users/tvd/.rvm/gems/ruby-1.9.3-p0@alchemy-2.1/gems/capistrano-2.11.2/lib/capistrano/cli/execute.rb:34:in `execute!'
    from /Users/tvd/.rvm/gems/ruby-1.9.3-p0@alchemy-2.1/gems/capistrano-2.11.2/lib/capistrano/cli/execute.rb:14:in `execute'
    from /Users/tvd/.rvm/gems/ruby-1.9.3-p0@alchemy-2.1/gems/capistrano-2.11.2/bin/cap:4:in `<top (required)>'
    from /Users/tvd/.rvm/gems/ruby-1.9.3-p0@alchemy-2.1/bin/cap:19:in `load'
    from /Users/tvd/.rvm/gems/ruby-1.9.3-p0@alchemy-2.1/bin/cap:19:in `<main>'

Closing comment (2012-05-19T05:40:17Z): This is a duplicate of #168.