Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

Debugging in RubyMine

Before using RubyMine, my debugging workflow went something like this:

Why isn’t this test passing?. It should’ve passed. Let me add a few Kernel#puts calls to see what’s going on. Hmmm, ok, it’s still failing. I’m going to need some more output. Man, these tests take forever to run. Syntax error?!. Ugh, typo…

Debugging like this isn’t fun; especially when pairing. Fortunately, RubyMine can help. RubyMine includes a standard debugger that has minimal setup and works out of the box. I still don’t enjoy debugging, but RubyMine has made it much less painful. In this post, we’ll look at debugging in RubyMine on OS X.

Setting Breakpoints

Add or remove breakpoints with command + F8.


View existing breakpoints with command + shift + F8.


Starting the Debugger

Debug the current program with control + shift + D. This will automatically open the Debug tool window (command + 5).


Use control + D to re-run the last debug session. View recent debug sessions with control + alt/option + D.


Examining a Program

Examine variables in the Debug tool window’s variables pane.


Use command + N in the Debug tool window’s Watches pane to watch a specific variable. backspace will delete a watch.


Use alt/option + F8 to evaluate arbitrary expressions. control + space triggers autocompletion.


Instead of using the Debug tool window, examine a variable inline by placing your cursor on it and pressing command + alt/option + F8.


Stepping through a Program

Step into a method with F7. Step over a method with F8. Step out of a method with shift + F8.

Use your cursor as a temporary breakpoint with alt/option + F9. Continue your debug session with F9.

Stop #puts’ing

If you’re using an IDE, take time to learn its debugger. Don’t litter your code with Kernel#puts and friends. Instead, set a breakpoint, start the debugger, examine some objects, and slowly step through your problems.

  1. Chad Woolley says:

    Thanks Jared,

    Another excellent addition to your series.

    I also wrote a blog post on this topic long ago, but mine was advocating against using GUI debuggers, because they really sucked back then (2008):

    My, how far we’ve come. I now use the RubyMine debugger regularly, it’s nice.

    However, it still has its pain points. One thing I notice, and maybe this is just our project, is that it always runs focused rspec examples TWICE when debugging. This is annoying, you’re often unsure if you’ve looped back to the second run, or if you’re entering a method twice. Anyone else have that problem or know how to fix it? I’ve been too lazy to enter a jetbrains ticket.

    The other thing is that it seems to lose its context if you get into some really hairy metaprogramming – it doesn’t know the class context or any local/instance vars.

    This seems to have been improved with RubyMine 5, I saw it more in RubyMine 5.

    — Chad

  2. Jared Carroll says:

    Thanks Chad. I’ve come across your post before. I tried command-line debugging in Ruby, but I prefer a GUI when debugging. I really like the variables and watch panes in RubyMine’s Debug tool window, because they allow you to quickly see all the locals. I haven’t come across the focused spec bug you’re seeing; maybe try doing it on a fresh Rails app to see if it’s just your project.

  3. Subhash says:

    Hi Jared,
    I am from Java Background and Ruby mine is somewhat different to Eclipse i used before.
    I need to ask a small doubt:

    Ruby Code
    Line1 Start
    Line4 End
    Lets say i have a debugger point Line 1 and Line 4.

    What would be the command to Go Directly to Line 4 , its not working with Shift F8
    and secondly i want to come out from Line 4 , what would be the command.

    In Eclipse this happens directly through F8.

    Subhash Negi

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *