This repository was archived by the owner on May 30, 2024. It is now read-only.
Avoid printing to stdout from Client or Ruby activation#868
Merged
Conversation
Contributor
|
Might another approach be to 'flush' stdout before starting ruby-lsp? |
Member
Author
|
I'm not sure how we'd go about doing that. It's the LSP package that owns the pipes, we don't have access to them. |
7c484b8 to
e197571
Compare
andyw8
approved these changes
Nov 2, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
STDOUTorSTDINfor anything when it comes to the client, because it may mess up the client-server communication.Implementation
I switched all places in
ClientandRubywhere 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.