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

RubyMine Configuration 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.

Written by Matt Haliski

The First of His Name, Consumer of Tacos, Operator of Computers, Mower of Grass, Father of the Unsleeper, King of Bad Function Names, Feeder of AI Overlords.