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

Debugger freezes on start without error #295

Open
vassyz opened this issue Jun 22, 2023 · 22 comments
Open

Debugger freezes on start without error #295

vassyz opened this issue Jun 22, 2023 · 22 comments

Comments

@vassyz
Copy link

vassyz commented Jun 22, 2023

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

@Sorc96
Copy link

Sorc96 commented Jun 30, 2023

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

@vassyz
Copy link
Author

vassyz commented Jun 30, 2023

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

@plfoley
Copy link

plfoley commented Jul 1, 2023

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.

@vassyz
Copy link
Author

vassyz commented Jul 1, 2023

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

@andyw8
Copy link
Contributor

andyw8 commented Jul 2, 2023

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

@plfoley
Copy link

plfoley commented Jul 2, 2023

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?

@vassyz
Copy link
Author

vassyz commented Jul 2, 2023

@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

@Sorc96
Copy link

Sorc96 commented Jul 3, 2023

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

@plfoley
Copy link

plfoley commented Jul 16, 2023

@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

@RuBAN-GT
Copy link

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

@bjaglin-swile
Copy link

bjaglin-swile commented Jul 20, 2023

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.

@vassyz
Copy link
Author

vassyz commented Jul 27, 2023

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

@arjunhamdalah
Copy link

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

image image

@wesharper
Copy link

Switching to 0.1.0 solved this issue for me as well.

@alexrecuenco
Copy link

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

@andyjeffries
Copy link
Contributor

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

@vassyz
Copy link
Author

vassyz commented Sep 14, 2023

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

@rmsy
Copy link

rmsy commented Sep 22, 2023

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.

@ko1
Copy link
Collaborator

ko1 commented Dec 27, 2023

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

@vassyz
Copy link
Author

vassyz commented Feb 11, 2024

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

@monochromec
Copy link

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.

@mgk
Copy link

mgk commented Feb 25, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests