2

I've set up the ruby-debug-ide and debase gems in my Rails application so that I can use VS Code's built-in debugging tools.

During development, I would like any exception to trigger a breakpoint and start the debugger in VS Code. How can I set this up?

ndbroadbent
  • 13,513
  • 3
  • 56
  • 85

1 Answers1

1

I was unable to do this using debase and recommend using gem debug instead, along with extension "VSCode rdbg Ruby Debugger".

You'll get a "rescue any exception" breakpoint which works (though I wasn't able to get it to rescue only uncaught exceptions).

enter image description here

See https://github.com/ruby/vscode-rdbg and https://github.com/ruby/debug

This is the launch.json for my rails application

{
    "type": "rdbg",
    "name": "Debug Rails with rdbg",
    "rdbgPath": "bundle exec rdbg",
    "request": "launch",
    "cwd": "${workspaceFolder}",
    "command": "${workspaceFolder}/bin/rails",
    "script": "server",
    "args": [
        "-p",
        "8080"
    ]
}
Bruno Degomme
  • 883
  • 10
  • 11