vscode-ruby version: 0.22.0ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]Working language server
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)
It looks like your default shell is set to bash but it isn't available in your path?
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.
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.
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).
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.
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.
Yep, it'll get fixed
@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.
Yes it is. Like I said, I'm going to need to figure out how to do it in a better cross-platform way.
@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
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
Please, let me know in any other details are required.
@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.
@wingrunr21 working perfectly for me now! Thanks!
vscode-ruby version: 0.22.2ruby 2.3.3p222 (2016-11-21 revision 56859) [x64-mingw32]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.
````
@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:
cmd.exe, PowerShell, or bash (either via Cygwin or the Linux subsystem)PATH or do you have to start you shell with a custom PATH?I am going to close this issue as I believe the problem for the Linux users is resolved.
@wingrunr21
Please see #438
@wingrunr21 it's OK now, thanks a lot!
@wingrunr21 thank you a lot! v0.22.2 fixes the problem.