capistrano/capistrano — Issue #168: Capture not working
Author: siannopollo
Created: 2012-02-23 20:25:32+00:00
State: open

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:

```ruby
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 `'
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 `

'

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