Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging ruby 3 code #92

Open
phyzical opened this issue Apr 4, 2022 · 13 comments
Open

Debugging ruby 3 code #92

phyzical opened this issue Apr 4, 2022 · 13 comments
Labels
bug Something isn't working

Comments

@phyzical
Copy link

phyzical commented Apr 4, 2022

Your environment

  • vscode-ruby-test-adapter version: 0.9.0
  • Ruby version: 3.0.3
  • VS Code version: 1.66.0
  • Operating System: osx
  • RSpec or Minitest version: 3.10.0

Expected behavior

as rdebug-ide is not compatible with ruby 3 a way to us the native gem debug or some other debugger

or does anyone know of a way to get rdbug-ide working with ruby 3?

@phyzical phyzical added the bug Something isn't working label Apr 4, 2022
@phyzical
Copy link
Author

phyzical commented Apr 4, 2022

should note i can debug by just going rdbg --open -- ${COMMAND} in the terminal then attach via a launch. but if i try to use this via the debug command flag it just doesnt start the socket to attach to? is the debug command built fairly strict for rdebug-ide only?

@connorshea
Copy link
Owner

Currently I believe so, yes

@phyzical
Copy link
Author

phyzical commented Apr 4, 2022

@connorshea thanks for the reply (my lazy dev brain loves the plugin).

hmm maybe ill look at the source and see how hard it would be to support rdbg as it seems to be the standard going forward in ruby land 👍

@rubensa
Copy link

rubensa commented Jul 20, 2022

Any news on supporting rdbg?

@rubensa
Copy link

rubensa commented Jul 20, 2022

I'm trying to make this work.
This are my settings for Ruby Test Explorer:

    // Ruby Test Explorer config
    "rubyTestExplorer.logpanel": true,
    "rubyTestExplorer.testFramework": "minitest",
    "rubyTestExplorer.filePattern": [
      "*_test.rb"
    ],
    "rubyTestExplorer.minitestCommand": "bundle exec rake",
    "rubyTestExplorer.minitestDirectory": "./test",
    "rubyTestExplorer.debugCommand": "bundle exec rdbg --open",

This is the config from lauch.json to attach to the rbdg session:

    {
      "name": "Attach with rdbg",
      "type": "rdbg",
      "request": "attach",
      "debugPort": "127.0.0.1:1234",
    },

When I try to debug a (Minitest) test, if I run the attach command quickly enough, the debugger makes the connection and It stops at debug_minitest.rb first line:

$LOAD_PATH << File.expand_path(__dir__)
require "vscode/minitest"

VSCode::Minitest.run(*ARGV)

But, as you can see in the log, the debugger is disconnected just after loading the Rails app and it does not stop at my break points.

[2022-07-20 09:48:36.362] [INFO] Debugging test(s) ["./test/assert_attributes_test.rb[5]"] of /workspaces/my-app
[2022-07-20 09:48:36.362] [INFO] Running Ruby tests ["./test/assert_attributes_test.rb[5]"]
[2022-07-20 09:48:36.364] [INFO] Starting the debug session
[2022-07-20 09:48:36.364] [INFO] Running single test: /workspaces/my-app/test/assert_attributes_test.rb:5
[2022-07-20 09:48:36.364] [INFO] Running command: bundle exec rdbg --open  --host 127.0.0.1 --port 1234 -- $EXT_DIR/debug_minitest.rb 'test/assert_attributes_test.rb:5'
[2022-07-20 09:48:36.749] [DEBUG] [CHILD PROCESS OUTPUT] DEBUGGER: Debugger can attach via TCP/IP (127.0.0.1:1234)
[2022-07-20 09:48:36.751] [DEBUG] [CHILD PROCESS OUTPUT] DEBUGGER: wait for debugger connection...
[2022-07-20 09:48:36.812] [DEBUG] [CHILD PROCESS OUTPUT] DEBUGGER: Connected.
[2022-07-20 09:48:39.311] [DEBUG] [CHILD PROCESS OUTPUT] DEBUGGER:  BP - Line  /workspaces/my-app/test/assert_attributes_test.rb:6 (line) is activated.
[2022-07-20 09:48:39.312] [DEBUG] [CHILD PROCESS OUTPUT] Loading Rails app...
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] DEBUGGER: Disconnected.
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] /opt/rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:319:in `check_for_activated_spec!': You have already activated minitest 5.16.1, but your Gemfile requires minitest 5.11.3. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /opt/rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:31:in `block in setup'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /opt/rbenv/versions/2.6.4/lib/ruby/2.6.0/forwardable.rb:230:in `each'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /opt/rbenv/versions/2.6.4/lib/ruby/2.6.0/forwardable.rb:230:in `each'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /opt/rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:26:in `map'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /opt/rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:26:in `setup'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /opt/rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler.rb:107:in `setup'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /opt/rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/setup.rb:20:in `<top (required)>'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /opt/rbenv/versions/2.6.4/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /opt/rbenv/versions/2.6.4/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /workspaces/my-app/config/boot.rb:3:in `<top (required)>'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /workspaces/my-app/config/application.rb:3:in `require_relative'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /workspaces/my-app/config/application.rb:3:in `<top (required)>'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /workspaces/my-app/test/test_helper.rb:4:in `require_relative'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /workspaces/my-app/test/test_helper.rb:4:in `<top (required)>'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /opt/rbenv/versions/2.6.4/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /opt/rbenv/versions/2.6.4/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /workspaces/my-app/test/assert_attributes_test.rb:1:in `<top (required)>'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /opt/rbenv/versions/2.6.4/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /opt/rbenv/versions/2.6.4/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /home/user/.vscode-server/extensions/connorshea.vscode-ruby-test-adapter-0.9.0/ruby/vscode/minitest/tests.rb:27:in `block in load_files'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /opt/rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/file_list.rb:79:in `each'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /opt/rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/file_list.rb:79:in `each'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /home/user/.vscode-server/extensions/connorshea.vscode-ruby-test-adapter-0.9.0/ruby/vscode/minitest/tests.rb:27:in `load_files'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /home/user/.vscode-server/extensions/connorshea.vscode-ruby-test-adapter-0.9.0/ruby/vscode/minitest/tests.rb:8:in `all'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /home/user/.vscode-server/extensions/connorshea.vscode-ruby-test-adapter-0.9.0/ruby/vscode/minitest/tests.rb:14:in `find_by'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /home/user/.vscode-server/extensions/connorshea.vscode-ruby-test-adapter-0.9.0/ruby/vscode/minitest/runner.rb:33:in `add_file_with_line'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /home/user/.vscode-server/extensions/connorshea.vscode-ruby-test-adapter-0.9.0/ruby/vscode/minitest/runner.rb:15:in `add'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /home/user/.vscode-server/extensions/connorshea.vscode-ruby-test-adapter-0.9.0/ruby/vscode/minitest.rb:35:in `block in run'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /home/user/.vscode-server/extensions/connorshea.vscode-ruby-test-adapter-0.9.0/ruby/vscode/minitest.rb:35:in `each'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /home/user/.vscode-server/extensions/connorshea.vscode-ruby-test-adapter-0.9.0/ruby/vscode/minitest.rb:35:in `run'
[2022-07-20 09:48:39.840] [DEBUG] [CHILD PROCESS OUTPUT] 	from /home/user/.vscode-server/extensions/connorshea.vscode-ruby-test-adapter-0.9.0/ruby/debug_minitest.rb:4:in `<main>'
[2022-07-20 09:48:39.846] [INFO] Child process has exited. Sending test run finish event.
[2022-07-20 09:48:39.846] [DEBUG] Parsing the below JSON:
[2022-07-20 09:48:39.846] [DEBUG] 
[2022-07-20 09:48:46.364] [ERROR] Failed starting the debug session - aborting debugCommandStarted timed out
[2022-07-20 09:48:46.364] [INFO] Killing currently-running tests.
[2022-07-20 09:55:06.350] [INFO] Debugging test(s) ["./test/assert_attributes_test.rb[5]"] of /workspaces/my-app
[2022-07-20 09:55:06.351] [INFO] Running Ruby tests ["./test/assert_attributes_test.rb[5]"]
[2022-07-20 09:55:06.351] [INFO] Starting the debug session
[2022-07-20 09:55:06.351] [INFO] Running single test: /workspaces/my-app/test/assert_attributes_test.rb:5
[2022-07-20 09:55:06.351] [INFO] Running command: bundle exec rdbg --open  --host 127.0.0.1 --port 1234 -- $EXT_DIR/debug_minitest.rb 'test/assert_attributes_test.rb:5'
[2022-07-20 09:55:06.755] [DEBUG] [CHILD PROCESS OUTPUT] DEBUGGER: Debugger can attach via TCP/IP (127.0.0.1:1234)
[2022-07-20 09:55:06.757] [DEBUG] [CHILD PROCESS OUTPUT] DEBUGGER: wait for debugger connection...
[2022-07-20 09:55:06.931] [DEBUG] [CHILD PROCESS OUTPUT] DEBUGGER: Connected.
[2022-07-20 09:55:16.351] [ERROR] Failed starting the debug session - aborting debugCommandStarted timed out
[2022-07-20 09:55:16.351] [INFO] Killing currently-running tests.
[2022-07-20 09:55:16.352] [INFO] Child process has exited. Sending test run finish event.
[2022-07-20 09:55:16.352] [DEBUG] Parsing the below JSON:
[2022-07-20 09:55:16.352] [DEBUG] 

Any ideas on why the debugger is disconnected? (and how I could fix the You have already activated minitest 5.16.1, but your Gemfile requires minitest 5.11.3. Prepending bundle exec to your command may solve this. (Gem::LoadError) message?

NOTE: I also have set the PARALLEL_WORKERS=1 env variable

@rubensa
Copy link

rubensa commented Jul 20, 2022

Finally had this "partially" working.

Changes in adapter.js (this part is not working as expected)

      const debuggerConfig = {
        name: "Debug Ruby Tests",
        type: "rdbg",
        request: "attach",
        debugPort: "127.0.0.1:1234"
      };

Changes in minitestTests.js

  getDebugCommand(debuggerConfig) {
    let command = vscode.workspace.getConfiguration('rubyTestExplorer', null).get('debugCommand') ||
      'rdebug-ide';
    return (`${command} ${process.platform == 'win32' ? '%EXT_DIR%' : '$EXT_DIR'}/debug_minitest.rb`);
  }

Ruby Test Explorer settings:

    // Ruby Test Explorer config
    "rubyTestExplorer.logpanel": true,
    "rubyTestExplorer.testFramework": "minitest",
    "rubyTestExplorer.filePattern": [
      "*_test.rb"
    ],
    "rubyTestExplorer.minitestCommand": "bundle exec rake --trace",
    "rubyTestExplorer.minitestDirectory": "./test",
    "rubyTestExplorer.debugCommand": "bundle exec rdbg --open --host 127.0.0.1 --port 1234 -c -- bundle exec ruby",

If I try to debug a test, starting the debug session always fail but, as the command is waiting for the debugger to connect, I can launch an attach command using following lauch.json config:

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

and the debugger stops at the beginning of debug_minitest.rb but also at my test break points.

@rubensa
Copy link

rubensa commented Jul 20, 2022

I suppose that the not working part (launching the debugger configuration) might be cause old vscode debug API usage or something.

@rubensa
Copy link

rubensa commented Jul 21, 2022

More info on this: It is only working with debug 1.5.0. With debug 1.6.1 it only stops at the beginning of debug_minitest.rb but not at my test break points 😞

@rubensa
Copy link

rubensa commented Jul 21, 2022

Looks like with debug 1.5.0 is working cause a bug making debug reuse the current debugging session. You can see that it tries to bind the debugging process to 127.0.0.1:1234 that is currently in use for the main debug process (that is debugging the debug_minitest.rb instead of the individual tests):

TESTS_PATTERN="*_test.rb" bundle exec rdbg --open --host 127.0.0.1 --port 1234 -c -- bundle exec ruby ~/.vscode-server/extensions/connorshea.vscode-ruby-test-adapter-0.9.0/ruby/debug_minitest.rb 'test/assert_attributes_test.rb:5'
DEBUGGER: Debugger can attach via TCP/IP (127.0.0.1:1234)
DEBUGGER: wait for debugger connection...
DEBUGGER: Connected.
DEBUGGER:  BP - Line  /workspaces/my-app/test/assert_attributes_test.rb:6 (line) is activated.
Loading Rails app...
Initializing Rails app...
Loading test instrumentation...
DEBUGGER: wait for debugger connection...
#<Thread:0x0000557c3a07a1c8@DEBUGGER__::Server::reader /opt/rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/debug-1.5.0/lib/debug/server.rb:44 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
        7: from /opt/rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/debug-1.5.0/lib/debug/server.rb:49:in `block in activate'
        6: from /opt/rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/debug-1.5.0/lib/debug/server.rb:393:in `accept'
        5: from /opt/rbenv/versions/2.7.6/lib/ruby/2.7.0/socket.rb:763:in `tcp_server_sockets'
        4: from /opt/rbenv/versions/2.7.6/lib/ruby/2.7.0/socket.rb:227:in `foreach'
        3: from /opt/rbenv/versions/2.7.6/lib/ruby/2.7.0/socket.rb:227:in `each'
        2: from /opt/rbenv/versions/2.7.6/lib/ruby/2.7.0/socket.rb:765:in `block in tcp_server_sockets'
        1: from /opt/rbenv/versions/2.7.6/lib/ruby/2.7.0/socket.rb:201:in `listen'
/opt/rbenv/versions/2.7.6/lib/ruby/2.7.0/socket.rb:201:in `bind': Address already in use - bind(2) for 127.0.0.1:1234 (Errno::EADDRINUSE)
["DEBUGGER Exception: /opt/rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/debug-1.5.0/lib/debug/thread_client.rb:1038",
 #<Errno::EADDRINUSE: Address already in use - bind(2) for 127.0.0.1:1234>,
 ["/opt/rbenv/versions/2.7.6/lib/ruby/2.7.0/socket.rb:201:in `bind'",
  "/opt/rbenv/versions/2.7.6/lib/ruby/2.7.0/socket.rb:201:in `listen'",
  "/opt/rbenv/versions/2.7.6/lib/ruby/2.7.0/socket.rb:765:in `block in tcp_server_sockets'",
  "/opt/rbenv/versions/2.7.6/lib/ruby/2.7.0/socket.rb:227:in `each'",
  "/opt/rbenv/versions/2.7.6/lib/ruby/2.7.0/socket.rb:227:in `foreach'",
  "/opt/rbenv/versions/2.7.6/lib/ruby/2.7.0/socket.rb:763:in `tcp_server_sockets'",
  "/opt/rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/debug-1.5.0/lib/debug/server.rb:393:in `accept'",
  "/opt/rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/debug-1.5.0/lib/debug/server.rb:49:in `block in activate'"]]
#<Thread:0x0000557c3a07a088@DEBUGGER__::SESSION@server /opt/rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/debug-1.5.0/lib/debug/session.rb:144 aborting> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
        7: from /opt/rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/debug-1.5.0/lib/debug/server.rb:49:in `block in activate'
        6: from /opt/rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/debug-1.5.0/lib/debug/server.rb:393:in `accept'
        5: from /opt/rbenv/versions/2.7.6/lib/ruby/2.7.0/socket.rb:763:in `tcp_server_sockets'
        4: from /opt/rbenv/versions/2.7.6/lib/ruby/2.7.0/socket.rb:227:in `foreach'
        3: from /opt/rbenv/versions/2.7.6/lib/ruby/2.7.0/socket.rb:227:in `each'
        2: from /opt/rbenv/versions/2.7.6/lib/ruby/2.7.0/socket.rb:765:in `block in tcp_server_sockets'
        1: from /opt/rbenv/versions/2.7.6/lib/ruby/2.7.0/socket.rb:201:in `listen'
/opt/rbenv/versions/2.7.6/lib/ruby/2.7.0/socket.rb:201:in `bind': Address already in use - bind(2) for 127.0.0.1:1234 (Errno::EADDRINUSE)
Traceback (most recent call last):
        7: from /opt/rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/debug-1.5.0/lib/debug/server.rb:49:in `block in activate'
        6: from /opt/rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/debug-1.5.0/lib/debug/server.rb:393:in `accept'
        5: from /opt/rbenv/versions/2.7.6/lib/ruby/2.7.0/socket.rb:763:in `tcp_server_sockets'
        4: from /opt/rbenv/versions/2.7.6/lib/ruby/2.7.0/socket.rb:227:in `foreach'
        3: from /opt/rbenv/versions/2.7.6/lib/ruby/2.7.0/socket.rb:227:in `each'
        2: from /opt/rbenv/versions/2.7.6/lib/ruby/2.7.0/socket.rb:765:in `block in tcp_server_sockets'
        1: from /opt/rbenv/versions/2.7.6/lib/ruby/2.7.0/socket.rb:201:in `listen'
/opt/rbenv/versions/2.7.6/lib/ruby/2.7.0/socket.rb:201:in `bind': Address already in use - bind(2) for 127.0.0.1:1234 (Errno::EADDRINUSE)
Loading test support files...

RUNNING: ./test/assert_attributes_test.rb[5]

PASSED: ./test/assert_attributes_test.rb[5]
START_OF_TEST_JSON{"version":"5.11.3","summary":{"duration":9.35,"example_count":1,"failure_count":0,"pending_count":0,"errors_outside_of_examples_count":0},"summary_line":"Total time: 9.35, Runs: 1, Assertions: 1, Failures: 0, Errors: 0, Skips: 0","examples":[{"description":"good attributes","full_description":"good attributes","file_path":"./test/assert_attributes_test.rb","full_path":"/workspaces/my-app/test/assert_attributes_test.rb","line_number":5,"klass":"AssertAttributesTest","method":"test_good_attributes","runnable":"AssertAttributesTest","id":"./test/assert_attributes_test.rb[5]","status":"passed"}]}END_OF_TEST_JSON
DEBUGGER: Disconnected.

I think this is fixed in 1.6.0 and that's the cause is not working with 1.6.1.

@ndbroadbent
Copy link

ndbroadbent commented Nov 23, 2022

@rubensa Thanks for your comments, I'm also very interested in this! I'm hoping that rdbg might make it easier to use Spring to speed up my RSpec tests. (See: #110.)

Were you able to make any further progress on this?

EDIT: I got rdbg working from a command in launch.json, but unfortunately the breakpoints stop working when I run tests with Spring. I think this is still the way to go though, since it's the built-in Ruby debugger.

@rubensa
Copy link

rubensa commented Nov 24, 2022

Sorry to tell but, for now, I could not make vscod-ruby-test-adapter to work.
For now I'm using some custom launch configurations like:

{
  "version": "0.2.0",
  "configurations": [
            {
              "name": "Debug test from current selected test name",
              "type": "rdbg",
              "request": "launch",
              "cwd": "${workspaceFolder}",
              "command": "",
              "script": "${workspaceFolder}/bin/rails",
              "useBundler": true,
              "bundlePath": "${workspaceFolder}/bin/bundle",
              "args": [
                "test",
                "${file}",
                "-n",
                "/$(sed 's/ /_/g' <<< '${selectedText}')/"
              ]
            },
            {
              "name": "Debug tests from current file",
              "type": "rdbg",
              "request": "launch",
              "cwd": "${workspaceFolder}",
              "command": "",
              "script": "${workspaceFolder}/bin/rails",
              "useBundler": true,
              "bundlePath": "${workspaceFolder}/bin/bundle",
              "args": [
                "test",
                "${file}"
              ]
            },
            {
              "name": "Debug tests from project",
              "type": "rdbg",
              "request": "launch",
              "cwd": "${workspaceFolder}",
              "command": "",
              "script": "${workspaceFolder}/bin/rails",
              "useBundler": true,
              "bundlePath": "${workspaceFolder}/bin/bundle",
              "args": [
                "test"
              ]
            }
  ]
}

@rubensa
Copy link

rubensa commented Feb 8, 2023

Since latest versions you need to add "useTerminal": true option as, otherwise "/$(sed 's/ /_/g' <<< '${selectedText}')/" is not properly evaluated.

{
  "version": "0.2.0",
  "configurations": [
            {
              "name": "Debug test from current selected test name",
              "type": "rdbg",
              "request": "launch",
              "cwd": "${workspaceFolder}",
              "command": "",
              "script": "${workspaceFolder}/bin/rails",
              "useBundler": true,
              "bundlePath": "${workspaceFolder}/bin/bundle",
              "args": [
                "test",
                "${file}",
                "-n",
                "/$(sed 's/ /_/g' <<< '${selectedText}')/"
              ],
              "useTerminal": true
            },
            {
              "name": "Debug tests from current file",
              "type": "rdbg",
              "request": "launch",
              "cwd": "${workspaceFolder}",
              "command": "",
              "script": "${workspaceFolder}/bin/rails",
              "useBundler": true,
              "bundlePath": "${workspaceFolder}/bin/bundle",
              "args": [
                "test",
                "${file}"
              ]
            },
            {
              "name": "Debug tests from project",
              "type": "rdbg",
              "request": "launch",
              "cwd": "${workspaceFolder}",
              "command": "",
              "script": "${workspaceFolder}/bin/rails",
              "useBundler": true,
              "bundlePath": "${workspaceFolder}/bin/bundle",
              "args": [
                "test"
              ]
            }
  ]
}

@rubaiz
Copy link

rubaiz commented May 16, 2024

2 years later and this is still an issue, maybe this extension has reached EOL?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants