views:

271

answers:

1

Hello. How is it possible to debug rake tasks?

When I write debugger it does not start:

NoMethodError: undefined method `run_init_script' for Debugger:Module
from /usr/local/lib/ruby/gems/1.8/gems/ruby-debug-base-0.10.3/lib/ruby-debug-base.rb:239:in `debugger'
from (irb):4

If I run rake my:task --debugger rake returns me to console immediately.

+4  A: 

I found the solution.

$ gem install ruby-debug $ ruby-debug rake my:task

SMiX
Really though you shouldn't be doing large amounts of logic in a rake task. Most of my rake tasks are one-liners that call a method on a model which is then fully covered with tests.
rspeicher
I am doing spider based on mechanize and I need debug some lines. All them in methods and not covered by tests yet.Thank you for the reply.
SMiX
@rspeicher, it's useful if you have a seed task
Midday
on my system is `rdebug` instead of `ruby-debug`
Midday