-
Notifications
You must be signed in to change notification settings - Fork 172
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 rails app #1731
Comments
Thank you for the bug report! I'm puzzled as to how it worked without any manual intervention in The only way to attach to an existing Ruby process is if that process was started with the debugger in the first place. Do you have any When you attach with |
With The key puzzling part for me is the |
The idea of the socket path is that we create those automatically for you when launching the debugger, so that you don't have to configure or select anything. For attach, it's a bit different though. The extension has no way of knowing where the socket was created, so that it can offer as an option for you to select. In terms of the command, I'm pretty they are equivalent, we're just using the long names for the arguments (i.e.: The Ruby LSP debug client will default to look for sockets inside @st0012, in retrospect that was a bit of an odd decision from our part. If you don't specify a |
It'd create a tmp folder and use it to host socket files, like:
The I think our original intention was to make sure this extension would only search and connect to the ones that are handled by it? And also Now back to the main question, I think we can probably just provide an example config entry for Rails apps, like:
And when users want to debug Rails apps, they use this action to start the server, which will automatically be attached with VS Code. @stage-rl would that work for you? |
Thanks for proposal. Actually it would probably take a more skilled Rails developer than myself to answer this. Currently my workflow based on recommendations I've seen is running bin/dev. This runs
This is running basically all day (or several days). For debugging I can attach with your extension and it works as expected (with occasional need to stop and rerun when it somehow doesn't break on breakpoints). I'm not sure I would be able to achieve the same with your proposal if what you plan to do is add additional arguments to |
FWIW, it's already possible to launch a Rails server with the debugger using the configuration Stan mentioned. But in this attach scenario, it's definitely not clear. I think we should
@stage-rl are you interested in taking a stab at any of these two? |
What I'm currently doing in my Rails app is to use the following initializer: # frozen_string_literal: true
if Rails.env.development?
FileUtils.mkdir_p("/tmp/ruby-lsp-debug-sockets/")
DEBUGGER__.open(nonstop: true, sock_path: "/tmp/ruby-lsp-debug-sockets/development.sock")
end I like this approach because the debugger is always ready to be attached, I don't need to stop the server and start it again to investigate some issue. It's similar to what @stage-rl is doing, but I also like the fact that I don't need to write a complicated command or use an alias, just plain |
I see, that @vinistock already implemented part of the solution. I can take a look and try to contribute, but it won't be very quick. While looking at other implementation I found they're invoking |
It's definitely worth checking what debug is doing for listing sockets. It must know which folder they are being put somehow. |
Hi, my first implementation (with no error handling) that works for implicitly generated sockets for remote debugging can be found here: I have never modified a vscode extension, so I'm kind of lost on how to proceed. Pls point me in the right direction. Thanks |
I think that's pretty close. There seems to be a few formatting issues, which you can fix with Do you want to open the PR already? It's easier to provide specific feedback there. |
I will do that next week when I return from holiday |
This issue is being marked as stale because there was no activity in the last 2 months |
The simplest way I was able to get this to work with minimal modifications to rails is to run
That creates a debug socket where ruby_lsp will look for it. Ensure you have a launch configuration like this in your launch.json:
Then run that configuration to attach to your debugger. |
Operating System
Debian Linux
Ruby version
3.2.2
Project has a bundle
Ruby version manager being used
rbenv
Description
Hello, tried to use the debugger for rails apps in "attach mode" and gave up several times returning to vscode-rdbg
Only after seeing this comment I tried running my rails app as
bundle exec rdbg --open --command --sock-path=/tmp/ruby-lsp-debug-sockets/test.sock -- bin/rails server -p 3000
and it works. This still required to manually create /tmp/ruby-lsp-debug-sockets folder. Still this is probably not the required approach.Can you pls add info on proper procedure to README? Thanks a lot and keep up the good work
The text was updated successfully, but these errors were encountered: