Debugging in RubyMine with Rails 5.2

April 04, 2018

Hey there! The winds have blown me in a new direction and this site is now just an archive for posterity's sake. All the new action will be happening at StayWildGames.com. I'll have a writeup detailing the move soon.

If you’ve upgraded to Rails 5.2 and are using RubyMine’s debugger you might notice that breakpoints aren’t working as they should. For me, they would only work in views, but controllers and models wouldn’t stop anything.

Turns out the problem is the inclusion of the Bootsnap gem in Rails 5.2. Bootsnap is awesome so you probably want to use it, but having a broken debugger sucks. So let’s fix it.

Step 1 - Set an ENV variable for debugging in RubyMine

  • Click Run > Debug...
  • Choose Edit Configurations...
  • Add an ENV variable to be included when the debugger boots Rails ENV['DEBUG_MODE'] = true

Debug Settings

  • Click Apply

Step 2 - Add conditional to boot.rb

Open up boot.rb and alter the bootsnap line like so

require 'bootsnap/setup' unless ENV['DEBUG_MODE']

Done!

Now, when you boot into development (or production) you get to take advantage of Bootsnap. But when you need to do some debugging you boot Rails without Bootsnap and your debugging functions like you think it should.

Happy coding.