-
Notifications
You must be signed in to change notification settings - Fork 173
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
Header must provide a Content-Length property #1723
Comments
Thank you for the bug report! It seems that some bundler output is getting mixed with the Ruby LSP's responses in STDOUT based on this line, which should only have included the content length.
Do you have any bundler configuration by any chance? I'm not sure how that bundler output ended up mixed in there - especially given that we redirect all bundler output to STDERR on the server. |
I'm experiencing the same issue, and also using rvm. |
I have the same issue after migrating from the Ruby and VSCode Ruby extensions. I did remove the old configuration (starting with "ruby.") and followed the Troubleshooting section. |
Folks, we'll need more information to be able to understand what's going on. If someone who can reproduce the issue help debug it would help a lot. The following script will run our custom bundle logic and capture anything that got printed to STDOUT. We need to understand what's being printed to STDOUT, because that's how the output would get mixed into responses that we send back to the editor. # Require the Ruby LSP's custom bundle logic
require "ruby_lsp/setup_bundler"
# Require StringIO
require "stringio"
# Save the current $stdout in a variable
current_stdout = $stdout
# Set $stdout to be a StringIO so that we can capture it
$stdout = StringIO.new
# Run the Ruby LSP's custom bundle logic
_bundle_gemfile, _bundle_path = RubyLsp::SetupBundler.new(Dir.pwd, **{}).setup!
# Get everything that was printed to STDOUT
content = $stdout.string
# Restore the original STDOUT
$stdout = current_stdout
# Show contents that were printed to STDOUT
puts "*" * 80
puts "STDOUT"
puts content |
@vinistock Happy to help but I don't understand what context this is supposed to run in? In the [project]/.ruby-lsp directory? Or replace something in the extension code? |
I think just running it in a terminal inside the project's directory ought to be enough (not |
I don't get any STDOUT:
|
Interesting...still not sure how other output is getting mixed up. Do you have any bundler configurations? @bricedurand are you also using RVM? Trying to understand if this problem is somehow related to RVM specifically. |
@vinistock I didn't dig into the extension code to see what it's doing, but reading just the console output, it seems like it gets past the bundle configuration. It says it's skipping the bundle setup as that has already been completed. So I'm not sure this is bundler output. It appears that the extension has both a client and server component, and the message is output when the extension is attempting to connect to the server. |
Based on the backtrace posted, it looks like bundler output is getting mixed into the responses we send back to the editor somehow.
That line should only contain the |
It looks like the message originates here, we might want to look at |
Switching to asdf did resolve this for me:
|
Thank you very much for helping diagnose this. It seems that it might be somehow related to RVM, although it's still a bit unclear why it's the only version manager that gets us into this state. I created a fix to guarantee that we never print anything to STDOUT and always use STDERR for Ruby activation. This should hopefully make any extraneous output go to STDERR and not mess up the LSP's communication. |
I released https://github.com/Shopify/vscode-ruby-lsp/releases/tag/v0.4.14 as a prerelease with the fix. If someone could please install the prerelease version and let us know if the fix worked, I'd really appreciate it. |
Works for me, thanks! |
Sorry for the late reply, I am using RVM indeed. |
Happy to hear that it worked. I'll close this for now, but please let us know if you find any other issues. |
Hi @vinistock, unfortunately the pre release v0.4.14 still isn't working for me. Here is the output I get
|
@bricedurand thank you for the backtrace, I think I figured out the problem now. You must have Bundler's log level configured to debug, because you're getting debug messages like this one printed to stdout (which messes up client/server communication). I put up a PR on the server to override the log level to |
@vinistock It is unlikely that I have Bundler's log level set to debug, I couldn't even find in the docs how to change it. |
You have There's only one place in the entire rubygems codebase where that string is printed, which is the point in the code that I linked to. It uses That said, there are multiple ways to configure it, one of them being the verbose flag. The resolver also accepts some environment variables |
If it helps anyone, I had the same issue resolved by updating bundler to |
@vinistock I checked bundle's config and the environment variables but couldn't find anything that sets the log level to debug. Tried uninstalling bundler and upgrading to the newest version but no luck either. EDIT : I finally got it to work after doing a fresh install of mac OS |
Works! |
I seem to be having this same issue, but the setup is quite different:
The LSP starts up fine and correctly detects my shell, version manager, etc. The problem only occurs when I ask it to format a file using the VSCode command palette:
It looks like the output of rubocop is being mixed in, but:
Could this be a problem with the Standard Ruby LSP addon? I noticed that I don't encounter this problem on other projects that do use the LSP but use rubocop instead of standardrb. |
@thatbudakguy could you create a separate issue for this please? It could be due to something quite different, and there's been a lot of changes since this was originally opened. |
Operating System
OSX Sonoma 14.0
Ruby version
3.2.2
Project has a bundle
Ruby version manager being used
rvm
Description
After opening a Ruby project using VSCode, I'm getting the following error when trying to initialize the Ruby LSP extension
The text was updated successfully, but these errors were encountered: