-
Notifications
You must be signed in to change notification settings - Fork 52
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
Comments
should note i can debug by just going |
Currently I believe so, yes |
@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 👍 |
Any news on supporting rdbg? |
I'm trying to make this work. // 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.
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 NOTE: I also have set the PARALLEL_WORKERS=1 env variable |
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. |
I suppose that the not working part (launching the debugger configuration) might be cause old vscode debug API usage or something. |
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 😞 |
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. |
@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 |
Sorry to tell but, for now, I could not make vscod-ruby-test-adapter to work. {
"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"
]
}
]
} |
Since latest versions you need to add {
"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"
]
}
]
} |
2 years later and this is still an issue, maybe this extension has reached EOL? |
There were a lot of pull requests, but still no reaction. And there does not appear to be a replacement. |
Your environment
vscode-ruby-test-adapter
version: 0.9.0Expected behavior
as rdebug-ide is not compatible with ruby 3 a way to us the native gem
debug
or some other debuggeror does anyone know of a way to get rdbug-ide working with ruby 3?
The text was updated successfully, but these errors were encountered: