ruby-on-railsherokuremote-debuggingvscode-debuggerheroku-cli

How to debug Ruby on Rails in Heroku Staging with VSCode


We've set up a Heroku Ruby on Rails API app and used the Pipeline feature to create a Production and Staging copy of the app. We develop on a Linux VM with VSCode Remote from Windows PCs and push code via Git to Heroku. But sometimes code/settings that work on localhost on Dev don't work quite the same on Heroku, and sometimes that requires using the debugger on Heroku. We found examples on Heroku's website and others on how to do this for Node.js and Java apps, but nothing other than upping the LOG_LEVEL environment variable to DEBUG seemed to be available for Ruby on Rails.

We're interested in anyone else that has successfully remotely debugged a Ruby on Rails Heroku app with VSCode and want to know if you found any easier/better way to do it.


Solution

  • It turns out that several things were needed:

    Once you've done the above, you can start VSCode debugging by pressing [F5], selecting the "Attach with rdbg to HEROKU STAGING..." choice in the VSCode debugger and starting a session.

    Then access your Staging app via browser or program after setting breakpoints and have at it!