castwide / vscode-solargraph

A Visual Studio Code extension for Solargraph.
Other
425 stars 23 forks source link

Unable to restart language server #89

Closed wldyslw closed 5 years ago

wldyslw commented 5 years ago

Hi, first of all, thank you a lot for a such useful extension!

My system:

On the very first launch of VS Code in current user session, extension starts normally as it should be. But if I'm trying to restart server via ctrl + shift + p -> Solargraph: Restart Solargraph, or by reloading VS Code itself, server does not start, constantly notifying me in editor's status bar "Starting the Solargraph language server...".

Output panel says literally nothing. The only interesting thing is that every try of restarting language server causes launching of process with command /usr/bin/zsh -i -c solargraph socket --port 0 which i guess supposed to be /usr/bin/zsh -i -c 'solargraph socket --port 0' (notice quotes) for correct launching.

jezman commented 5 years ago

Same problem... Gem downgrading doesn't help.

wldyslw commented 5 years ago

Gem downgrading doesn't help.

As for me, downgrading extension to 0.17.6 fortunately solves this issue

mattwelke commented 5 years ago

I am not able to reproduce this. Whether I start VS Code from scratch, reload the window, or reload the extension, it always goes from Starting the Solargraph language server... to Solargraph is ready. quickly.

I use Ubuntu with rbenv, with version 0.18.0 of the Ruby Solargraph extension. I use no configuration in VS Code regarding Ruby. I allow the extension to detect things automatically based on what I have installed. However, I do have the $HOME/.rbenv/bin and $HOME/.rbenv/shims directories added to my PATH.

~ > lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:    18.04
Codename:   bionic
~ > which rbenv
/home/matt/.rbenv/bin/rbenv
~ > rbenv -v
rbenv 1.1.1-39-g59785f6
~ > which ruby
/home/matt/.rbenv/shims/ruby
~ > ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
~ > which solargraph
/home/matt/.rbenv/shims/solargraph
~ > solargraph -v
0.29.4
~ > code -v
1.29.1
bc24f98b5f70467bc689abf41cc5550ca637088e
x64
wldyslw commented 5 years ago

I've realized that the problem is definitely with my default shell which is zsh. Setting bash as default shell solves problem with extension.

castwide commented 5 years ago

Thanks to everyone for all the feedback on this issue. I think @wldyslw is on the right track with how the server process gets launched from zsh. I have a possible solution; if it works, I'll report here and publish it in a patch release.

castwide commented 5 years ago

The most recent extension (vscode-solargraph 0.19.0) and gem (solargraph 0.30.0) should resolve this issue. Tested with zsh on MacOS.

wldyslw commented 5 years ago

I've tried it out, and looks like everything is working now. Thank you a lot for investigating this issue!

droznyk commented 5 years ago

I have the same problem for two weeks. I'm using asdf instead of rbenv.

 ~  lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:    18.04
Codename:   bionic
 ~  which asdf    
/home/patryk/.asdf/bin/asdf
 ~  asdf --version
v0.6.1
 ~  which ruby
/home/patryk/.asdf/shims/ruby
 ~  ruby -v
ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
 ~  which solargraph
/home/patryk/.asdf/shims/solargraph
 ~  solargraph -v
0.31.0
 ~  code -v
1.30.2
61122f88f0bf01e2ac16bdb9e1bc4571755f5bd8
x64
 ~  echo $0
/usr/bin/zsh
castwide commented 5 years ago

@droznyk I'm not familiar with asdf, so I can't suggest anything to troubleshoot it specifically.

One thing you can try is setting the extension's solargraph.commandPath configuration to the path you got from which solargraph.

droznyk commented 5 years ago

@castwide Oh man, you're great! It worked. :) Thank you so much!

jemminger commented 5 years ago

I'm on 0.19.1, macOS 10.14.2, and on some of my larger Rails projects the status bar never progresses past "Starting the solargraph language server..."

castwide commented 5 years ago

@jemminger How large are the projects? e.g., number of files, approx. lines of code, and number of gems.

Do you get any errors in the developer console (Help -> Toggle Developer Tools)?

Improving load times for large projects is an ongoing concern. For comparison, the castwide/solargraph repo takes about 20 seconds to initialize in VS Code, and rails/rails takes about 2 minutes.

jemminger commented 5 years ago

@castwide Interesting, the console showed that the gem wasn't installed despite the extension being installed. I think this happened because I recently blew away my RVM install and started over.

I manually installed solargraph now and it initialized as expected in about 20 seconds.

May be a bug that I wasn't prompted to install the gem?

castwide commented 5 years ago

Yes, that's a bug. The extension should notify you when the gem isn't installed and/or it couldn't start the server. Related: #100

hughevans commented 5 years ago

https://github.com/castwide/vscode-solargraph/issues/89#issuecomment-454691848

After ~6 months of trying on and off to get Solargraph in VS Code to work this actually fixed it for me. Admittedly I never tried very hard and I’m now very happy that it’s working, but I think this is probably a pretty prevalent issue.

chaffeqa commented 4 years ago

https://github.com/castwide/vscode-solargraph/issues/89#issuecomment-454691848

I agree, ☝️ that comment held the key for me, i use asdf and AFAIK there are x2 options:

  1. you can add gem solargraph, group: [:development] to your Gemfile in the working project, and then check the Solargraph: Use Bundler option in Settings VScode view (to make sure it uses bundle exec or it will not find it)
  2. you can install the gem locally (make sure you are on the correct RVM, rubyenv, asdf gemset/ruby version/shim, and run gem install solargraph, then run which solargraph, copy that output, and put it into the Solargraph: Command Path in Settings VScode view