Skip to content

I have to restart debug session for breakpoints to work after code is edited #44

@rockorequin

Description

@rockorequin

Whenever I save a file in VSCode, eg to make a code change, breakpoints no longer work until I restart the debug session.

I'm running VSCode in Windows 11 with the application in a WSL Ubuntu 22.04 container running ruby 3.1.2 (installed via rvm), and I'm using the master branch of the debug gem from https://github.com/ruby/debug.

To reproduce this, I created a new rails project with rails 7.0.3 (rails new testdebug) and then added:

config/routes.rb:

resource :things, only: :index
root "things#index"

app/controllers/things_controller.rb:


class ThingsController < ApplicationController
  def index
    j=1
  end
end

and a view, app/views/things/index.erb.

My launch.json file is:


{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "type": "rdbg",
      "name": "Debug Rails",
      "request": "launch",
      "script": "${workspaceRoot}/bin/rails",
      "cwd": "${workspaceRoot}",
      "args": [ "server" ],
      "askParameters": false,
      "serverReadyAction": {
        "pattern": "listening on http://127.0.0.1:([0-9]+)",
        "uriFormat": "http://localhost:%s",
        "action": "openExternally"
      }
    },
    {
      "type": "rdbg",
      "name": "Attach with rdbg",
      "request": "attach"
    }
  ]
}

Then I set a breakpoint on the line j=1 in things_controller.rb#index. When I run the debug session, it stops at this line as expected, and whenever I refresh the webpage, it also stops at this line as expected.

But as soon as I make a code change, or even just save the things_controller.rb file without making any changes, when I refresh the page the code no longer stops at the breakpoint. The breakpoint still shows as enabled in the breakpoints window as "things_controller.rb app/controllers".

Have I misconfigured something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions