Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Make extension work on Windows #712

Merged
merged 3 commits into from
Aug 4, 2023
Merged

Conversation

vinistock
Copy link
Member

Motivation

Closes Shopify/ruby-lsp#1586

According to the explorations reported in the issue, Windows seems to need two things

  1. The shell: true in the LSP executable. This doesn't seem to make any difference for MacOS or Linux
  2. We need to remove the single quotes around commands when executing them without this.shell

Implementation

Added shell: true and avoided adding the single quotes if this.shell is not defined.

Manual Tests

On Windows,

  1. Clone the repo
  2. Switch to this branch
  3. yarn install
  4. Click F5 to start running the development version of the extension (alternatively, go to Run and Debug and click the launch button)
  5. In the new window opened, be sure to navigate to a Ruby project where you can test the Ruby LSP
  6. Verify the Ruby LSP booted properly. You can do this in multiple ways, you can
  • Check if any of the features are available
  • Go to the Output tab in the window where the Ruby project is opened and check for a Ruby LSP is ready message

@vinistock vinistock added bugfix This PR will fix an existing bug os:windows This issue is relevant only to Windows labels Jul 21, 2023
@vinistock vinistock added this to the 2023-Q3 milestone Jul 21, 2023
@vinistock vinistock self-assigned this Jul 21, 2023
@blm768
Copy link

blm768 commented Jul 23, 2023

This gets the initialization process further in, but it eventually fails with the following message in the developer console:

Error: Command failed: BUNDLE_GEMFILE=c:\Users\REDACTED\Dev\ruby-test\.ruby-lsp\Gemfile bundle exec ruby -e "require 'ruby-lsp'; print RubyLsp::VERSION"
'BUNDLE_GEMFILE' is not recognized as an internal or external command,
operable program or batch file.

Most typical shells on Windows don't support the VAR=value COMMAND syntax, so we might have to set the environment variable a different way.

@vinistock vinistock force-pushed the vs/make_extension_work_on_windows branch from c098715 to 9eb2e21 Compare July 24, 2023 13:56
@vinistock
Copy link
Member Author

@blm768 thank you for helping verify this. I appreciate the assistance!

The latest commit moves BUNDLE_GEMFILE to be properly passed through the env option of the executable rather than preceding the command. Please, let us know if this makes the extension work.

@blm768
Copy link

blm768 commented Jul 27, 2023

That gets it into a new restart loop. It doesn't give much in the way of helpful error messages, but this might be relevant:

ERR ENOENT: no such file or directory, realpath 'extension-output-Shopify.ruby-lsp-#1-Ruby LSP': Error: ENOENT: no such file or directory, realpath 'extension-output-Shopify.ruby-lsp-#1-Ruby LSP'

@vinistock vinistock force-pushed the vs/make_extension_work_on_windows branch from 9eb2e21 to 0290113 Compare July 27, 2023 13:40
@vinistock
Copy link
Member Author

I think we're almost there. Thank you again for your assistance testing this out.

If it reached the error restart loop, then it might be related to some of the recent bugs that are fixed in main. I rebased this branch to get those in here. Please, give it another try with the updated branch.

If it still doesn't work after the rebase, then could you please try to boot the server manually and report any issues? To do that

  1. Make sure your Ruby version is >= 3.0 (we do not support rubies that are past EOL)
  2. Make sure you have ruby-lsp v0.7.4 installed (gem install ruby-lsp)
  3. Inside the folder for the project that you're trying to use the LSP in, run ruby-lsp (no bundle exec)
  4. If it shows Ruby LSP is starting, then it booted properly and reached the main LSP loop. If this is the case, then something is still wrong with the extension side
  5. If anything fails with the server, it should print something to the terminal and then we know the issue is on the server side

@blm768
Copy link

blm768 commented Jul 27, 2023

Looks like ruby-lsp itself has a similar environment variable issue.

@vinistock
Copy link
Member Author

Thank you for testing it. I put up a PR to fix that and I hope that after shipping both PRs, it will work properly on Windows.

@vinistock vinistock marked this pull request as ready for review July 27, 2023 21:09
@vinistock vinistock requested a review from a team as a code owner July 27, 2023 21:09
@vinistock vinistock requested review from andyw8 and egiurleo July 27, 2023 21:09
@blm768
Copy link

blm768 commented Aug 1, 2023

Looks like after the other PR, I'm getting the following in the extension debugging host's Debug Console:

rejected promise not handled within 1 second: Error: ENOENT: no such file or directory, realpath '/c:/Users/REDACTED/Dev/ruby-test/test.rb'
stack trace: Error: ENOENT: no such file or directory, realpath '/c:/Users/REDACTED/Dev/ruby-test/test.rb'
rejected promise not handled within 1 second: Error: Pending response rejected since connection got disposed
[... stack trace in VSCode stuff, probably not much useful here ...]
rejected promise not handled within 1 second: Error: Client is not running and can't be stopped. It's current state is: starting

I then get a number of additional "Client is not running" errors with the state set to startFailed.

I'm not sure how we're getting into realpath since the only exact matches for that search term seem to be in yarn.lock.

@tonklon
Copy link

tonklon commented Aug 4, 2023

This PR also fixes the issues with spaces in the path to the Gemfile, I was trying to solve in #716. Just tested on macOS and it works as expected.

@vinistock
Copy link
Member Author

Merging this as I believe these were the last bits from the extension. The rest of the work is on the server and ongoing.

@vinistock vinistock merged commit f7df30c into main Aug 4, 2023
@vinistock vinistock deleted the vs/make_extension_work_on_windows branch August 4, 2023 17:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bugfix This PR will fix an existing bug os:windows This issue is relevant only to Windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed to activate Ruby
4 participants