-
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
"Debugger exited with status 1" for request=launch even though I'm able to execute the same command myself and then debug with request=attach #1767
Comments
Any suggestions on what to do? If I'm given a quick primer on where to go and put some console.log and alike to provide more information on what exactly is failing, I'm happy to do it. Especially: tell me where you suspect is the line that triggers the "Debugger exited with status 1", and I'll take it from there. |
Thank you for the bug report! In the latest version of the extension, we started printing the debug server backtrace to the debug console if spawning fails. If you try again, do you see the backtrace? That might help uncover what's failing. |
Unfortunately, the latest version doesn't work for me at all but that's unrelated to this issue. Shopify/vscode-ruby-lsp#923 (comment) I'll come back to this one when RVM ends up working in the pre-release version. |
This issue is being marked as stale because there was no activity in the last 2 months |
We have shipped better RVM support in the stable version of the extension. If you can try this again, hopefully the debug console will print whatever errors occurred in the server, which can help us understand what's going on. |
This issue is being marked as stale because there was no activity in the last 2 months |
I'll have a look this week. Sorry for the wait. |
I'll close this one for now. Since we shipped the upgraded integration for RVM, we have not received any related bug reports, so I'm hoping this has been fixed too. If that's not the case, please do re-open. |
Aight, thank you @vinistock. |
Hi. Unfortunately i am currently experiencing the same issue after the installing the most recent version of the vs code extension and the most up to date ruby-lsp gem. There are no error reports in the ruby-lsp output of vscode. I also tried running the command manually and attaching the debugger afterwards, which works well. |
@vinistock As far as i know i do not have configured a particular bundler config The only thing that i have configured is the number of jobs for bundler.
|
I meet the same problem, even the .ruby-lsp folder is not created! And I will exit if I click the debug button |
@vinistock It turned it this issue wasn't caused by RVM. I've not been encountering this issue for a while now, until I was able to trigger it again. Here's what happened. First, I decided to bump
So I set a breakpoint before This shouldn't really ever happen, given Ruby LSP uses Bundler when present on the project. But it is happening. So I do So, I install it back with I'm in a pickle here. Unsure why/how Ruby LSP decides it should use an incorrect version of a dependency... And how it comes up with that version number to use in particular, given that gem version doesn't exist. Any ideas what I could do, and what data to supply back, to help find the cause of this? I checked #2519 and it seems unrelated. And I'm rocking Ruby LSP extension v0.7.20 so it should be fixed if it's at play. |
Whoa! Ruby LSP does not obey Gemfile.lock! A change in
It also wants a change in
So when ...This is of course totally unexpected, since Now that I know the root cause, I can keep the version number of this dependency in my Gemfile, but let's take a step back and come up not just with a fix, but a generic logging mechanism that could help catch problems like these. What could "Ruby LSP" print in "Output" window to help understand the issue at hand? What's currently printed there is irrelevant to debugging this. And that exit 1 comes from somewhere... Nothing in stdout/stderr as Ruby LSP tries to run it? There could be a clue about missing |
I also noticed that after the first successful run of Ruby LSP with |
Thank you very much for all the information, this is extremely helpful. This is what I believe to be happening:
Based on what you're saying, we're launching the debugger using the lockfile before it was updated somehow. The puzzling part for me is: are you not seeing the language server restart automatically upon modifying the lockfile? I would've expected the restart to automatically correct the custom lockfile, which would then make launching the debugger work. EDIT: I also just realized this: the Ruby LSP debug client only attaches the debugger to the running process, but it doesn't control which dependencies are loaded by that process. Are you restarting the process you want to attach the debugger to after upgrading the gem? That could explain the behaviour you're seeing, since the process would be using the old version of the gem. |
Thanks for getting back to me @vinistock. Appreciate your help here.
Uhm... And if I execute
Unsure, since I use my own terminal to execute
I use VS Code on a daily basis. I also turn off my computer every day. That means Ruby LSP starts from scratch many times. However, the issue persisted across Ruby LSP restarts. That indicates it's not really about
Please don't get distracted by This issue is solely about |
@Nowaker can you share the contents of your vscode debugging configuration? |
|
Whenever the server launches, be it due to a restart, re-opening VS Code, automatic file watcher restart or any other trigger, we always check if the contents of the main lockfile are not matching the contents of the custom lockfile, so that we can then re-copy and start from scratch (see this line). Updating a gem, even if you do it in a separate terminal or with the editor closed, should make no difference. When you open VS Code, it will compare the SHA digest of the previous lockfile content vs the current one and re-generate if needed. Based on this comment
I suspect there's some Bundler related issue at play. We don't even watch the Gemfile or do anything with it, since what controls the versions is the lockfile. The only impact that adding a constraint to the Gemfile would have is to force Bundler to resolve versions in a certain way. Do you happen to have any global ( |
Yes:
But I was already on that version when I found the cause of this issue.
I mean, it surely is about Bundler. But it isn't a Bundler issue alone - it's an issue triggered by Ruby LSP. Bundler alone works fine, I can It's clear as day it's something in Ruby LSP triggering this incorrect behavior, and all my experience tells me it's a caching mechanism. Old Gemfile.lock? I can't tell. Ruby LSP has some caching - a quick search reveals this one, for example: ruby-lsp/lib/ruby_lsp/setup_bundler.rb Line 94 in a4f5a2d
And I'm also unsure if this entire bundle setup thing is happening for
AFAIR, I even replicated the same environment variables back then. And it would still just start, and listen. And then I would attach from VS Code. But having the plugin do it, it exits 1. If we're back to square one, let's go back to February:
Nope. No backtrace. Still the same output as before. I've recorded a video for you to see how easy it is for me to reproduce this issue and show it's about an old dependency being retained (somehow).
It's pretty clear my |
I see the same, but opposite, issue. The RubyLsp generated lockfile does not obey the contents of my projects own lockfile. For at least the immediately problematic gem, it selected a much newer version (dry-monads 1.6.0 vs 1.3.5), which my application is not compatible with. This dependency gem is not declared in my Gemfile, its a dependency of a dependency, and the version is not specified where its declared. But either way, I would ASSUME the RubyLsp would honour my projects lockfile and not go pick its own versions. So when I run the rdbg command from the terminal from my workspace root, everything is fine and I can happily attach. But when I use CodeLens, I assume the extension is telling it to use the Lsp gemfile via I'm wondering to myself, why would I want the debug process to use the lsp gemfile? That itself seems like a bug. I'm going to try and fix this myself and put up a PR. But also, the gem versioning thing is concerning, but I don't know enough about the Lsp to know what else this could be affecting. |
Wait, the plugin generates its own
Too bad I never saw Why [is this entire bundle setup thing happening for |
There was a time when it didn't do this custom bundle for debugging, but then one day this: f55b903 It's a nice feature IF the users repo didn't include the debug gem, but when it does, its causing these issues. I guess the history/usage of the custom bundle expanded over time so what was once an edge case is the every case. |
Nice find. Allowing us to opt out of using LSP's bundle would be as easy as this: if (fs.existsSync(customGemfilePath) && !debugConfiguration.env.IGNORE_LSP_BUNDLER) {
debugConfiguration.env.BUNDLE_GEMFILE = customGemfilePath;
} But a proper fix would be to actually "Fix debugger launch configurations when debug is not included in the bundle" and not "Force RubyLsp::SetupBundler whether debug gem is in the bundle or not". Because it is in mine, and yet RubyLsp::SetupBundler is happening for no good reason. |
I noticed that the .ruby-lsp/Gemfile.lock was heavily outdated compared to my projects gemfile. As a quickfix to be able to debug deletion of this .ruby-lsp/Gemfile.lock or the whole .ruby-lsp folder worked for me to be able to debug again. |
Removing the chunk of code that sets |
I've got a pull request up for adding a new setting, which allows users to specify the path to the Gemfile to use when running in debug. If the setting is blank, nothing changes. This fixes the issue I was having, where the Gemfile the LSP generated in the lsp-ruby file had newer and incompatible versions of gems I used, and thus failed when parsing the code it was running. This fixes that, and it works fine, as long as your Gemfile contains the debug gem. |
I'm running into a similar (but possibly different? no incompatible gems) issue. I can run it just fine via normal
Things Tried
|
Just wanted to share an update: I managed to reproduce this with tests and I believe I have a fix for it. It's related to how the composed bundle environment is not reported back to the extension, which makes us try to launch the debugger with the wrong Bundler settings. I'm waiting on PR reviews until I can submit the related changes. Once everything is in replace, I'll ask the folks here to test it out. |
@vinistock Thanks! |
### Motivation Closes #1767, closes #1785 Merge the composed bundle environment into the workspace's Ruby object. The language server sets up the composed bundle environment, returns it, and then we merge that into the Ruby object to ensure that any other parts of the extension are using the exact same environment. This fixes a few issues people have been experiencing with the debug client. ### Implementation Started merging the composed environment into the Ruby object and then started relying on that for the debug client. ### Automated Tests Added some tests. I will follow up with another PR that creates an integration test for a scenario that currently fails.
I'm running into what seems to be the exact same issue on the latest versions of the extension (v0.8.15) and the server (v0.22.1). OS: Windows launch.json:
Output when I try to launch:
And then I get the "Debugger exited with status 1" message. |
@RolandMunsil please log a new issue for this so that we can more easily track. |
Actually, I seem to have ended up getting it working? I'm not sure exactly which things I tried were necessary, but removing |
@RolandMunsil please do create the new issue. I thought Maybe there's some RubyGems gotcha with that platform value and we need to broaden it to include Windows too. |
Operating System
Linux
Ruby version
3.3.0 / 3.1.4
Project has a bundle
Ruby version manager being used
rvm
Description
Executing the exact same command from the log
bundle exec rdbg --open --command --sock-path=/tmp/ruby-lsp-debug-sockets/ruby-debug-worldmodern-0.sock -- puma
succeeds. And I can attach a debugger from there with no issue, so something isn't adding up.I tried bumping the dependencies, but it didn't help. Still exit 1.
Neither Ruby 3.3.0 nor Ruby 3.1.4 works on this computer. Linux + RVM.
The exact same application with
launch.json
on my other computer works. Mac + RVM.The text was updated successfully, but these errors were encountered: