This repository has been archived by the owner on May 30, 2024. It is now read-only.
Avoid printing to stdout from Client or Ruby activation #868
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
This may be the solution for Shopify/ruby-lsp#1723.
I suspect the issue is that RVM is somehow causing something to be printed to STDOUT, which is basically left in the pipe until the LSP starts. When it finally does start, it reads STDOUT and gets the stuff that was printed, which is invalid from the LSP's perspective.
I'm not 100% sure this is the fix, but in general we should simply never use
STDOUT
orSTDIN
for anything when it comes to the client, because it may mess up the client-server communication.Implementation
I switched all places in
Client
andRuby
where we were using STDOUT to get versions or perform activation. We now rely only on STDERR, which in LSPs is only used for printing and not for communication.