ruby-on-railsrubyruby-debug

Rails logs show `DEBUGGER: Debugger can attach via UNIX domain socket` but VS Code rdbg says "Can not find attachable Ruby process."


I have two Rails apps that I want to debug with the VS Code rdbg Ruby Debugger extension.

For each of them, I have a launch.json that looks like this (abbreviated):

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "rdbg",
      "name": "Attach with rdbg",
      "request": "attach"
    }
  ]
}

And I'm invoking my Rails server with RUBY_DEBUG_OPEN="true".

However, in one of my apps I can attach to the running Rails server and in the other I can't. In the non-working app, I see:

Can not find attachable Ruby process.

I think something about the socket might be relevant. The debugger shows this output in the logs for the working app:

11:02:52 web.1  | DEBUGGER: Debugger can attach via UNIX domain socket (/var/folders/ry/743cy7l57qlg1c3jq_yy4qc40000gn/T/rdbg-501/rdbg-22368)

and the non-working app, I see:

11:06:08 web.1  | DEBUGGER: Debugger can attach via UNIX domain socket (/var/folders/ry/743cy7l57qlg1c3jq_yy4qc40000gn/T/ruby-debug-sock-501/ruby-debug-sam-23097)

The socket name there starts with ruby-debug-sock-, not rdbg-, which seems relevant, since I am trying to use rdbg.


Solution

  • It turned out to be caused by having an old version of the ruby/debug gem.

    In the working app, ruby/debug was 1.9.2 (I looked in Gemfile.lock) and in the non-working site, it was 1.8.0.

    When I upgraded the version of ruby/debug, the socket name changed to have the rdbg- prefix and I could attach the debugger.