vscode-rdbg icon indicating copy to clipboard operation
vscode-rdbg copied to clipboard

Debugger freezes on start without error

Open zarembas opened this issue 2 years ago • 22 comments

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.

Screenshot 2023-06-22 at 11 00 54

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

zarembas avatar Jun 22 '23 10:06 zarembas

I have this problem as well. Absolutely no idea what could be wrong, I can't find any feedback anywhere.

Sorc96 avatar Jun 30 '23 08:06 Sorc96

I don't use the debugger that often, but this might be a dealbreaker for a lot of people. Hopefully somebody addresses it shortly.

zarembas avatar Jun 30 '23 08:06 zarembas

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? image

If you have, maybe the issue you are encountering is related to what is reported here.

plfoley avatar Jul 01 '23 14:07 plfoley

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:

Screenshot 2023-07-01 at 16 10 40

These are my settings:

Screenshot 2023-07-01 at 16 12 12

zarembas avatar Jul 01 '23 15:07 zarembas

@vassyz those settings are for a different extension, https://github.com/Shopify/vscode-ruby-lsp

andyw8 avatar Jul 02 '23 13:07 andyw8

What I was asking is if you configured the Ruby Version Manager you use in the Rdbg settings.

In VSCode:

  1. Go to Settings
  2. in the search bar type: Rdbg: Ruby Version Manager What 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 avatar Jul 02 '23 13:07 plfoley

@plfoley Sorry, as @andyw8 mentioned above I screenshotted the settings from ruby-lsp. The one you asked about is set to asdf.

Screenshot 2023-07-02 at 16 58 55

zarembas avatar Jul 02 '23 16:07 zarembas

I'm using rvm, if that information helps. The little blue progress bar below Run and debug starts moving and nothing else happens afterwards.

Sorc96 avatar Jul 03 '23 09:07 Sorc96

@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

plfoley avatar Jul 16 '23 16:07 plfoley

I used the same workaround, but after a second reattach I see the error: connect ENOENT. For the program I use Socket approach.

RuBAN-GT avatar Jul 18 '23 06:07 RuBAN-GT

FWIW, I am using asdf with zsh (& oh-my-zsh), and got around the freeze by:

  1. 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))
    
  2. Setting useTerminal to true, to use the asdf-backed shims just as an interactive user would

I assume this workaround should cover all version managers.

bjaglin-swile avatar Jul 20 '23 21:07 bjaglin-swile

I tried with "None" as Ruby Version Manager and "rdbgPath": "~/.asdf/shims/rdbg" and it still freezes.

zarembas avatar Jul 27 '23 19:07 zarembas

I tried downgrading the extension to 0.1.0 and it worked for me. I hope this workaround works well for you.

image image

arjunhamdalah avatar Jul 31 '23 23:07 arjunhamdalah

Switching to 0.1.0 solved this issue for me as well.

wesharper avatar Aug 24 '23 21:08 wesharper

Switching to 0.1.0 solved the issue for me as well! There must be some regression :(

(ruby 2.7)

A couple of things.

  1. I noticed that when I open rdbg, if you have output on your zshrc, it tries to run that output as a command.
  2. Breakpoints are not working for me in 0.2.x
  3. 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 socket TWICE
  4. Therefore, I still can only attach to it, running rdbg --open --command bundle exec rails server and then using the request: attach in launch.json
  5. the socket that it opens when you run it with launch can't be found when you later try attach, 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

  1. If the file has a space it doesn't work, you need to add the double quotes
  2. When I just run on a file like test.rb the attached at the bottom it says Couldn't start debug session. The debuggee process exited with code 7
# test.rb
puts "hi"

puts :jey

alexrecuenco avatar Sep 12 '23 16:09 alexrecuenco

Just to add, I had the same thing as @bjaglin-swile and unsetting rubyVersionManager worked for me too. Thanks @bjaglin-swile !!

andyjeffries avatar Sep 13 '23 09:09 andyjeffries

I can confirm that now setting rubyVersionManager to none instead of asdf works for me as well.

zarembas avatar Sep 14 '23 10:09 zarembas

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.

rmsy avatar Sep 22 '23 17:09 rmsy

Can someone provide step-by-step repro scenario I cant try?

ko1 avatar Dec 27 '23 06:12 ko1

@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.

zarembas avatar Feb 11 '24 23:02 zarembas

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.

monochromec avatar Feb 16 '24 12:02 monochromec

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.

mgk avatar Feb 25 '24 16:02 mgk