Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Language server crash on startup #433

Closed
meddario opened this issue Feb 20, 2019 · 19 comments
Closed

Language server crash on startup #433

meddario opened this issue Feb 20, 2019 · 19 comments
Assignees
Labels
bug Bug reports

Comments

@meddario
Copy link

Your environment

  • vscode-ruby version: 0.22.0
  • Ruby version: ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
  • Ruby version manager (if any): rvm 1.29.6
  • VS Code version: 1.31.0
  • Operating System: Ubuntu 18.04
  • Using language server? Yes

Expected behavior

Working language server

Actual behavior

The language server crashes with this error message (happens only if i enable the languageserver feature).

[Info  - 21:45:24] Initializing Ruby language server...
[Info  - 21:45:25] Rebuilding tree-sitter for local Electron version
[Info  - 21:45:25] Rebuild succeeded!
/home/dario/.vscode/extensions/rebornix.ruby-0.22.0/server/node_modules/rxjs/internal/util/hostReportError.js:4
    setTimeout(function () { throw err; });
                             ^

Error: Request workspace/rubyEnvironment failed with message: Command failed: /home/dario/.vscode/extensions/rebornix.ruby-0.22.0/client/out/util/shims/env.bash
/usr/bin/env: "bash -i": File o directory non esistente


    at handleResponse (/home/dario/.vscode/extensions/rebornix.ruby-0.22.0/server/node_modules/vscode-jsonrpc/lib/main.js:436:48)
    at processMessageQueue (/home/dario/.vscode/extensions/rebornix.ruby-0.22.0/server/node_modules/vscode-jsonrpc/lib/main.js:263:17)
    at Immediate.setImmediate (/home/dario/.vscode/extensions/rebornix.ruby-0.22.0/server/node_modules/vscode-jsonrpc/lib/main.js:247:13)
    at runCallback (timers.js:696:18)
    at tryOnImmediate (timers.js:667:5)
    at processImmediate (timers.js:649:5)
@wingrunr21
Copy link
Collaborator

It looks like your default shell is set to bash but it isn't available in your path?

@meddario
Copy link
Author

meddario commented Feb 20, 2019

I think that this is because the command /usr/bin/env bash -i can't work on Linux (works in macos, maybe some gnu vs bsd thing).

If i modify the shell script like this the error disappears:

#!/usr/bin/env bash

bash -i -c export

but a new error shows up:

[Info  - 22:32:51] Initializing Ruby language server...
[Info  - 22:32:51] Rebuilding tree-sitter for local Electron version
[Info  - 22:32:51] Rebuild succeeded!
Lint: executing rubocop -s /home/dario/Dev/Projects/dm/test/test.rb -f json...
events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at WriteWrap.afterWrite [as oncomplete] (net.js:833:14)
Emitted 'error' event at:
    at onwriteError (_stream_writable.js:431:12)
    at onwrite (_stream_writable.js:456:5)
    at _destroy (internal/streams/destroy.js:40:7)
    at Socket._destroy (net.js:603:3)
    at Socket.destroy (internal/streams/destroy.js:32:8)
    at WriteWrap.afterWrite [as oncomplete] (net.js:835:10)
[Info  - 22:32:53] Connection to server got closed. Server will restart.
[Error - 22:32:53] Request textDocument/foldingRange failed.
Error: Connection got disposed.
	at Object.dispose (/home/dario/.vscode/extensions/rebornix.ruby-0.22.0/client/node_modules/vscode-jsonrpc/lib/main.js:876:25)
	at Object.dispose (/home/dario/.vscode/extensions/rebornix.ruby-0.22.0/client/node_modules/vscode-languageclient/lib/client.js:71:35)
	at LanguageClient.handleConnectionClosed (/home/dario/.vscode/extensions/rebornix.ruby-0.22.0/client/node_modules/vscode-languageclient/lib/client.js:2150:42)
	at LanguageClient.handleConnectionClosed (/home/dario/.vscode/extensions/rebornix.ruby-0.22.0/client/node_modules/vscode-languageclient/lib/main.js:150:15)
	at closeHandler (/home/dario/.vscode/extensions/rebornix.ruby-0.22.0/client/node_modules/vscode-languageclient/lib/client.js:2137:18)
	at CallbackList.invoke (/home/dario/.vscode/extensions/rebornix.ruby-0.22.0/client/node_modules/vscode-jsonrpc/lib/events.js:62:39)
	at Emitter.fire (/home/dario/.vscode/extensions/rebornix.ruby-0.22.0/client/node_modules/vscode-jsonrpc/lib/events.js:120:36)
	at closeHandler (/home/dario/.vscode/extensions/rebornix.ruby-0.22.0/client/node_modules/vscode-jsonrpc/lib/main.js:226:26)
	at CallbackList.invoke (/home/dario/.vscode/extensions/rebornix.ruby-0.22.0/client/node_modules/vscode-jsonrpc/lib/events.js:62:39)
	at Emitter.fire (/home/dario/.vscode/extensions/rebornix.ruby-0.22.0/client/node_modules/vscode-jsonrpc/lib/events.js:120:36)
	at IPCMessageReader.fireClose (/home/dario/.vscode/extensions/rebornix.ruby-0.22.0/client/node_modules/vscode-jsonrpc/lib/messageReader.js:111:27)
	at ChildProcess.constructor.eventEmitter.on (/home/dario/.vscode/extensions/rebornix.ruby-0.22.0/client/node_modules/vscode-jsonrpc/lib/messageReader.js:213:45)
	at ChildProcess.emit (events.js:187:15)
	at maybeClose (internal/child_process.js:961:16)
	at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)

Edit: changed the command, not quite sure it works this way.

@wingrunr21
Copy link
Collaborator

Hmm, ok I'll need to look at how to make that more cross-platform. That file is generated based on the login shell so it'll need to also work with ZSH and such

The EPIPE is because rubocop isn't being found in the path you are trying to lint. Looks like Electron reports an EPIPE differently in Linux than in MacOS.

@meddario
Copy link
Author

meddario commented Feb 20, 2019

I did a few searches, but didn't found out a way to do this in a portable way (for example, using set -i to switch to interactive is not possible).
Here https://superuser.com/questions/280927/usr-bin-env-interpreter-arguments-portable-scripts-with-arguments-for-the there are a few suggestions, don't know if they are useful for this case (I'm not a big unix expert).

Regarding the error, maybe it's just a different error, probably the bash -i -c export command doesn't even make sense (it starts an interactive shell, but with a command).

@wingrunr21
Copy link
Collaborator

Ya, that solution took me awhile. What I may end up doing is writing different environment loading templates for different platforms. I'll take a look at fixing this tonight. I've got a couple other bugs I need to address.

@wingrunr21 wingrunr21 added the bug Bug reports label Feb 20, 2019
@wingrunr21 wingrunr21 self-assigned this Feb 20, 2019
@klyonov
Copy link

klyonov commented Feb 21, 2019

I have the same problem on Ubuntu 18.04.
If I modified file this way

/usr/bin/env bash -i
export

it would not fail and server would start as usual.

@wingrunr21
Copy link
Collaborator

Yep, it'll get fixed

@meddario
Copy link
Author

@klyonov maybe I'm wrong, but if you remove the shebang in that way, the script will have a different behaviour: the two lines /usr/bin/env bash -i and export will be executed separately, this is different from executing the export command inside a bash -i session.

@wingrunr21
Copy link
Collaborator

Yes it is. Like I said, I'm going to need to figure out how to do it in a better cross-platform way.

@klyonov
Copy link

klyonov commented Feb 22, 2019

@meddario thanks, I had a lot of new readings because of your comment. Now I know a little more about shebang etc.
I think in my case file can be changed this way

#!/usr/bin/bash -i
export

@soulim
Copy link

soulim commented Feb 22, 2019

In my case the language server initialization fails with another reason:

[Info  - 12:25:09 PM] Initializing Ruby language server...
[Info  - 12:25:09 PM] Rebuilding tree-sitter for local Electron version
[Error - 12:25:10 PM] Server initialization failed.
  Message: Request initialize failed with message: No prebuilt binaries found (target=undefined runtime=undefined arch=undefined platform=undefined)
  Code: -32603 
  • macOS Mojave 10.14.3 (18D109)
  • VS Code 1.31.1
  • fish 3.0.0

Please, let me know in any other details are required.

@wingrunr21
Copy link
Collaborator

@soulim that is a different issue than this one. Looks related to prebuild-install. I upgraded that in v0.22.2. Can you try that version and open a new issue if the problem persists?

@meddario @klyonov can you both try v0.22.2? I switched to just calling the default shell directly (similar to what @klyonov's solution was). I was getting the expected behavior on my Ubuntu VM.

@meddario
Copy link
Author

@wingrunr21 working perfectly for me now! Thanks!

@clxy
Copy link

clxy commented Feb 25, 2019

Your environment

  • vscode-ruby version: 0.22.2
  • Ruby version: ruby 2.3.3p222 (2016-11-21 revision 56859) [x64-mingw32]
  • VS Code version: 1.31.1
  • Operating System: Windows 7 64bit
  • Using language server? Yes

Actual behavior

After updated to 0.22.2, Got error like this:

[Info  - 10:05:37] Initializing Ruby language server...
[Info  - 10:05:37] Rebuilding tree-sitter for local Electron version
[Info  - 10:05:38] Rebuild succeeded!
c:\Users\s37120.MICTOKYO\.vscode\extensions\rebornix.ruby-0.22.2\server\node_modules\rxjs\internal\util\hostReportError.js:4
    setTimeout(function () { throw err; });
                             ^

Error: Request workspace/rubyEnvironment failed with message: Command failed: C:\Users\s37120.MICTOKYO\.vscode\extensions\rebornix.ruby-0.22.2\client\out\util\shims\env.cmd.exe
'C:\Windows\system32\cmd.exe -i' This verison of this file is not compatible with the version of Windows you're running. Check your computer's system information to see whether you need an x86 (32-bit) or x64 (64-bit) verion of the program...

    at handleResponse (c:\Users\s37120.MICTOKYO\.vscode\extensions\rebornix.ruby-0.22.2\server\node_modules\vscode-jsonrpc\lib\main.js:436:48)
    at processMessageQueue (c:\Users\s37120.MICTOKYO\.vscode\extensions\rebornix.ruby-0.22.2\server\node_modules\vscode-jsonrpc\lib\main.js:263:17)
    at Immediate.setImmediate (c:\Users\s37120.MICTOKYO\.vscode\extensions\rebornix.ruby-0.22.2\server\node_modules\vscode-jsonrpc\lib\main.js:247:13)
    at runCallback (timers.js:696:18)
    at tryOnImmediate (timers.js:667:5)
    at processImmediate (timers.js:649:5)
[Info  - 10:05:39] Connection to server got closed. Server will restart.

@wingrunr21
Copy link
Collaborator

@clxy Please open a new issue with this information! I need more information on how Windows users have their environments set up!

Specifically, I would like to know:

  • If you are using cmd.exe, PowerShell, or bash (either via Cygwin or the Linux subsystem)
  • how do you have Ruby installed? (RubyInstaller? some other way? is it in your system PATH or do you have to start you shell with a custom PATH?
  • How do you manage multiple versions of Ruby?

@wingrunr21
Copy link
Collaborator

I am going to close this issue as I believe the problem for the Linux users is resolved.

@clxy
Copy link

clxy commented Feb 25, 2019

@wingrunr21
Please see #438

@klyonov
Copy link

klyonov commented Feb 25, 2019

@wingrunr21 it's OK now, thanks a lot!

@soulim
Copy link

soulim commented Feb 25, 2019

@wingrunr21 thank you a lot! v0.22.2 fixes the problem.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bug reports
Projects
None yet
Development

No branches or pull requests

5 participants