castwide / solargraph-utils

A Node module for interacting with the Solargraph rubygem.
Other
5 stars 10 forks source link

Unable to start server on port 0 #1

Closed ghost closed 6 years ago

ghost commented 6 years ago

Not sure what's causing this, but I'm unable to use the VSCode solargraph extension as a result of an error coming from this package.

From what I can tell, attempting to start on TCP port 0 is the root cause of the issue. If I set the port passed in to the solargraph process (by modifying the Server class manually), everything starts working fine.

For example, changing this line from var args = ['server', '--port', '0']; to var args = ['server', '--port', '37654']; causes the issue to go away.

OS: Arch Linux x64

> uname -a
Linux <HOSTNAME> 4.14.10-1-ARCH #1 SMP PREEMPT Fri Dec 29 20:17:35 UTC 2017 x86_64 GNU/Linux
castwide commented 6 years ago
  1. Is there an error you can see in the VS Code console?
  2. Can you confirm version numbers for the Solargraph gem and VS Code extension?

Binding to port 0 should make the OS select the next available port. Since multiple workspaces might need to run in different environments (e.g., different Ruby versions, gemsets, etc.), each instance needs to select its own port to avoid conflicts.

When the server starts correctly, the VS Code console should give you a line like this:

INFO  WEBrick::HTTPServer#start: pid=##### port=#####

Solargraph-utils looks for that line to confirm that the server is running.

A previous version of the gem used Thin instead of WEBrick, which caused problems on some systems.

ghost commented 6 years ago

Solargraph extension version 0.10.3 Solargraph Gem version 0.15.4

image

castwide commented 6 years ago

Thanks. That's a new error for me. I'll try to reproduce it. If nothing else, it's possible for the application to select an available port instead of relying on the server handler.

castwide commented 6 years ago

I've published new versions of the gem, the VS code extension, and the solargraph-utils package. The one that's most pertinent to this issue is the gem. It uses its own routine to find an available port instead of requesting port 0 from the server handler.

ghost commented 6 years ago

Using the above mentioned latest versions (extension 0.11.0, gem 0.16.0), the original issue no longer manifests.

Thanks for the fix! I just started playing with Ruby and the lack of a working autocomplete extension for VSCode was really slowing me down.