ruby / debug

Debugging functionality for Ruby
BSD 2-Clause "Simplified" License
1.14k stars 127 forks source link

Setting breaking points with absolute path fails from nvim-dap and rdbg on Docker container #1050

Closed avucic closed 11 months ago

avucic commented 11 months ago

Your environment

Describe the bug When I run my nvim ruby adapter and set breakpoint I'm receiving error: Error setting breakpoints: /abs/path/to/spec/my_spec is not available.

Even with that error debugger will continue with first breakpoint at require 'rubygems' and if I press continue it will run the entire testing package until it comes to the desired breakpoint

To Reproduce This is something that I tried outside my editor:

In docker terminal in existing container: docker compose exec test rdbg --open --port 12345 --host 0.0.0.0 -c -- rspec spec/my_spec.rb:65

In second docker terminal docker compose exec test rdbg -A and then (rdbg:remote) b /abs/path/to/spec/my_spec:65 # No such file or directory @ rb_check_realpath_internal

With relative path it works.

Expected behavior Not to run whole suite and to stop immediately at my break point.

Additional context

Based on RUBY_DEBUG_LOCAL_FS_MAP my adapter should pass absoluthe path which will be transformed to remote local path.

To be frank I'm not sure who is "responsible" for this transformation rdbg or nvim-dap. There are similar issue with go/delve. However, it looks like delve have builtin path substation substitutePath

I tried with the option RUBY_DEBUG_LOCAL_FS_MAP=/app:${workspaceFolder} which doesn't help based on this localfsMap

I was testing this with this adapter call running rdbg manually in my terminal:

        callback({
          type = "server",
          host = "127.0.0.1",
          port = "12345",
          executable = {
            command = "task",
            args = {
              "debug",
              "--",
              "rdbg",
              "-A",
            },
          },
        })

(task debug will call docker exec)

  "configurations": [
    {
      "type": "ruby",
      "name": "Rdbg rspec current spec",
      "request": "attach",
      "command": "rspec",
      "script": "${relativeFile}:${currentLine}"
    },
]
avucic commented 11 months ago

It looks like parsing paths isn't the issue. However, there are problems with following: when I run this. command: docker compose exec -i test rdbg --open --host 0.0.0.0 --port 12345 -c -- bundle exec rspec spec/models/my_spec.rb:207 and run attach cofiguration from vscode everything works as expected. Debugger will run single spec and execute breakpoint.

However I can't manage to work from Neovim. When I attach the editor to the debugger instead of running one test it will run all my tests until it stops at the desired location. Any idea what I'm missing here?

Also both editors stops at the first line. Why is that?

Thanks in advance