Using the Ruby approach to debug a Rake project
As you already know that a Rake project is a Ruby project; therefore, all manipulations that you may use with a Ruby project can be applied to Rake project. So, you are able to use general debuggers from the Ruby world.
Currently, there are two tools to debug the Ruby code: debugger
and pry
. While these tools may be used for the debugging process, they are slightly different type of tools: the debugger
tool is specifically a debugger in many programming languages, but the pry
tool is an improved console that is designed to work in multiple contexts, including the applications running in the background. We can use either as per our requirement. The idea is the same for both of these tools, and the following steps will be performed for each:
Install the tool.
Add a breakpoint.
Run a rake task. The code will be paused on the breakpoint.
Investigate the environment.
Note
debugger
andpry
are third-party tools. You can find more information about them...