vscode-rdbg: rdbg in Gemfile not working

Even with setting “Use Bundler” set, debug installed with Gemfile causes Command Not Found error.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15

Most upvoted comments

@ko1 Thanks for this hint. I couldn’t start rdbg with Bundler either, but your command works!

It starts the Rails server, attaches the debugger and breakpoints are hit and you can inspect the variables.

This launch.json works for me debugging with Rails 7:

 {
  "version": "0.2.0",
  "configurations": [
    {
      "type": "rdbg",
      "name": "Debug Rails with rdbg",
      "rdbgPath": "bundle exec rdbg",
      "request": "launch",
      "cwd": "${workspaceFolder}",
      "command": "${workspaceFolder}/bin/rails",
      "script": "server"
    }
  ]
}

And now the following workflow is possible:

  • Go to some Rails Controller action
  • Set Breakpoint using VS Code editor
  • Go to VS Code Debug pane and run the “Debug Rails with rdbg” script
  • Rails server starts without problem
  • Visit the Controllers URL
  • Breakpoint stops execution and allows to inspect the methdo

I think this is because

https://github.com/ruby/vscode-rdbg/blob/636388aa96a66fa976afa3a1bc62d370592c682a/src/extension.ts#L193-L201

Is not happening in the context of ${workspaceFolder}

I get the same error code when I run the command outside my workspaceFolder

-- $ bundle exec rdbg --util=gen-sockpath
Could not locate Gemfile or .bundle/ directory

-- $ echo $?
10

I was able to work around this by setting "rdbgPath": "cd ${workspaceFolder} && bundle exec rdbg",

This seems a tad dangerous that the extension will just execute anything in placed in rdbgPath, but this workaround seems to work for now.