vscode-rdbg
vscode-rdbg copied to clipboard
Debugger freezes on start without error
When I try to run "Debug Rails with rdbg" the server doesn't start. It just seems to freeze. Same with "Attach with rdbg". Nothing seems to happen.
I'm not sure how to debug it as I don't have any errors popping.
laungh.json:
{
"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"
},
{
"type": "rdbg",
"name": "Attach with rdbg",
"request": "attach"
}
]
}
macOS 13.4 VSCode 1.79.2 rdbg 1.8.0 Ruby 3.2.2 Rails 7.0.5
I have this problem as well. Absolutely no idea what could be wrong, I can't find any feedback anywhere.
I don't use the debugger that often, but this might be a dealbreaker for a lot of people. Hopefully somebody addresses it shortly.
When you say that it freezes, do you mean you see a spinner beside the debug button or you mean VSCode freezes altogether?
Have you set a Version manager in RDBG settings for VSCode?
If you have, maybe the issue you are encountering is related to what is reported here.
I'm not very familiar with how it should work, but when I start debugging nothing happens and I can't stop it by clicking on the debug menu here:
These are my settings:
@vassyz those settings are for a different extension, https://github.com/Shopify/vscode-ruby-lsp
What I was asking is if you configured the Ruby Version Manager you use in the Rdbg settings.
In VSCode:
- Go to Settings
- in the search bar type:
Rdbg: Ruby Version ManagerWhat is the value of this parameter?
I don't recognize the extension you use to display your Ruby environment informations in the status bar. It looks nice, what is it?
@plfoley Sorry, as @andyw8 mentioned above I screenshotted the settings from ruby-lsp.
The one you asked about is set to asdf.
I'm using rvm, if that information helps. The little blue progress bar below Run and debug starts moving and nothing else happens afterwards.
@vassyz @Sorc96
The only thing that works for me is to set the Ruby Version Manager to "None"
In the launch.json file you may need to specify the path to rdbg as such:
"rdbgPath": "~/.rbenv/shims/rdbg", (Replace rbenv with the path your version manager uses)
Although I don't need to do this since I configured loading my version manager ~/.zprofile instead of ~/.zshrc
I used the same workaround, but after a second reattach I see the error: connect ENOENT.
For the program I use Socket approach.
FWIW, I am using asdf with zsh (& oh-my-zsh), and got around the freeze by:
- As suggested above, unsetting
rubyVersionManager, in order to skip the code which should setup the ruby environment but ends up freezing (the iterm2 integration does not seem to be the culprit as removing it does not change anything):➜ ps aux | grep -v grep | grep RUBY_ENV_ACTIVATE brice.jaglin 60254 0.0 0.0 408272416 3840 ?? S 9:40PM 0:00.05 /bin/zsh -lic asdf exec ruby -rjson -e printf(%{RUBY_ENV_ACTIVATE%sRUBY_ENV_ACTIVATE}, JSON.dump(ENV.to_h)) - Setting
useTerminaltotrue, to use theasdf-backed shims just as an interactive user would
I assume this workaround should cover all version managers.
I tried with "None" as Ruby Version Manager and "rdbgPath": "~/.asdf/shims/rdbg" and it still freezes.
I tried downgrading the extension to 0.1.0 and it worked for me. I hope this workaround works well for you.
Switching to 0.1.0 solved this issue for me as well.
Switching to 0.1.0 solved the issue for me as well! There must be some regression :(
(ruby 2.7)
A couple of things.
- I noticed that when I open rdbg, if you have output on your zshrc, it tries to run that output as a command.
- Breakpoints are not working for me in 0.2.x
- In rails. I can't get it to work by just running it, in either version, it executes, you see DEBUGGER: Connected. and then it disconnects. When running rails rdbg outputs the
DEBUGGER: Debugger can attach via UNIX domain socketTWICE - Therefore, I still can only attach to it, running
rdbg --open --command bundle exec rails serverand then using therequest: attachin launch.json - the socket that it opens when you run it with
launchcan't be found when you later tryattach, so you can't re-attach when it gets disconnected, (It also doesn't show you as disconnected, just in the UI you loose the debugger)
If I run a "debug current file" two things
- If the file has a space it doesn't work, you need to add the double quotes
- When I just run on a file like
test.rbthe attached at the bottom it says Couldn't start debug session. The debuggee process exited with code 7
# test.rb
puts "hi"
puts :jey
Just to add, I had the same thing as @bjaglin-swile and unsetting rubyVersionManager worked for me too. Thanks @bjaglin-swile !!
I can confirm that now setting rubyVersionManager to none instead of asdf works for me as well.
Confirming also that manually setting rdbgPath to ~/.asdf/shims/rdbg, instead of setting rubyVersionManager to asdf, "fixed" this for me. So it seems something related to rubyVersionManager (+ maybe asdf specifically?) is broken.
Can someone provide step-by-step repro scenario I cant try?
@ko1 I haven't used the extension since, but I've just selected asdf as the Ruby version manager and it worked fine. I'll continue testing it for a while.
Experiencing the very same behaviour as the original issue reporter. Ruby version manager is "none" in the extension settings and the launch.json contains the following configuration (which causes the debugging to freeze):
{ "name": "Debug Local File with rdbg", "type": "rdbg", "rdbgPath": "/opt/homebrew/opt/ruby/bin/rdbg", "request": "launch", "script": "${file}" },
Downgrading to 0.1 didn't solve the issue but caused the following error: "/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require': incompatible library version - /opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/gems/3.3.0/extensions/arm64-darwin-23/3.3.0/debug-1.9.1/debug/debug.bundle (LoadError) from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require'
from /opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/debug-1.9.1/lib/debug/frame_info.rb:16:in rescue in <module:DEBUGGER__>' from /opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/debug-1.9.1/lib/debug/frame_info.rb:13:in module:DEBUGGER__'
from /opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/debug-1.9.1/lib/debug/frame_info.rb:3:in <top (required)>' from /opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:31:in require_relative'
from /opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:31:in <top (required)>' from /opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/debug-1.9.1/lib/debug/open.rb:10:in require_relative'
from /opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/debug-1.9.1/lib/debug/open.rb:10:in <top (required)>' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require' /opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/debug-1.9.1/lib/debug/frame_info.rb:14:in require_relative': cannot load such file -- /opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/debug-1.9.1/lib/debug/debug.so (LoadError)
from /opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/debug-1.9.1/lib/debug/frame_info.rb:14:in <module:DEBUGGER__>' from /opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/debug-1.9.1/lib/debug/frame_info.rb:3:in <top (required)>'
from /opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:31:in require_relative' from /opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:31:in <top (required)>'
from /opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/debug-1.9.1/lib/debug/open.rb:10:in require_relative' from /opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/debug-1.9.1/lib/debug/open.rb:10:in <top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require'"
Platform is Ruby 3.3.0 (installed via Homebrew) running on OSX 14.3.1 with debug gem version 1.9.1 installed using VSCode Version: 1.86.2 Commit: 903b1e9d8990623e3d7da1df3d33db3e42d80eda Date: 2024-02-13T19:42:12.210Z Electron: 27.2.3 ElectronBuildId: 26908389 Chromium: 118.0.5993.159 Node.js: 18.17.1 V8: 11.8.172.18-electron.0
Please let me know if more info is required - more than happy to help.
I was getting:
[Error on session]
Error: connection closed
e: {}
errors debugging rails minitest tests.
Rails 6.0+ runs tests in parallel
Setting PARALLEL_WORKERS to 1 solved it for me:
{
"type": "rdbg",
"name": "Debug current test",
"request": "launch",
"script": "${file}",
"command": "bin/rails test",
"env": { "PARALLEL_WORKERS": 1 },
"askParameters": true
}
I notice that successful debug sessions also end with:
[Error on session]
Error: connection closed
e: {}
So I suspect that multiple processes in "launch" mode are the problem since a debug session can (I assume) only be attached to a single process.
I am using fish, asdf, Ruby 3.0, and Rails 6.1. I tried the version manger setting, useTerminal, and rdbgPath suggestions above. None of those worked in my case.