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
,it returns me to console immediately. How is it possible to debug rake tasks?
I found the solution.
or on some systems
ByeBug is another one for 2.0+
https://github.com/deivid-rodriguez/byebug
Visual Studio Code has pretty good debugger, built-in. If anybody finds this searching for a way to get it to work with rake, here's a working configuration:
This would run the rake task
all
. You may have to change the path to rake, I didn't find way to run the one in PATH.I highly recommend pry for this
In your rake task file:
This approach did not work for me. I just added this in my code:
Andrey Kouznetsov's answer didn't work for me using Ruby 1.9.3. The ruby-debug gem doesn't seem to support Ruby 1.9. I had to use the debugger gem: https://github.com/cldwalker/debugger.
gem 'debugger'
to my Gemfile's development group.bundle
.require 'debugger'
to the top of my rake task.debugger
where I wanted a breakpoint in my rake task.rake my:task
.