Closed pablox-cl closed 6 years ago
After diving into the code (I have basic understanding of js/ts), it seems that the problem is cross-spawn
, that doesn't recognize wsl paths.
Nevertheless I found a workaround (use a .bat
wrapper):
@echo off
bash -c "~/.rbenv/shims/solargraph %*"
I still have problems solargraph not being able to follow correctly requires (and almost everyone outside the stdlib says it doesn't exist; but that's a different problem)
Thanks for figuring that out. That's the most success I've heard from anyone trying to connect VS Code in Windows to Solargraph in WSL.
If the unfound requires are gems, you might be missing YARD documentation. There's an option to Build new gem documentation
in the VS Code command palette, or you can run yard gems
from a terminal.
For anyone who's looking for clearer instructions for the work around by @pablox-cl https://github.com/castwide/vscode-solargraph/issues/80#issuecomment-423748289 using rvm and WSL1:
which solargraph
in bash and copy the pathwhich solargraph
to replace {{SOLARGRAPH_PATH}}
@echo off
bash -c "{{SOLARGRAPH_PATH}} %*"
bin
with wrapper
in the path. (e.g. /home/mtamdev/.rvm/gems/ruby-2.6.0@dev-project/bin/solargraph %*
-> /home/mtamdev/.rvm/gems/ruby-2.6.0@dev-project/wrappers/solargraph %*
"solargraph.commandPath": "C:\\Max\\solargraph.bat"
@mtam2 Where do you run which solargraph
on? On ubuntu or command prompt?
@OrkunSA Run which solargraph
in ubuntu bash.
@mtam2 I just did and I got /home/dikilikid/.rvm/gems/ruby-2.6.1/bin/solargraph
I am sorry man I am really new to this world and if I am asking stupid questions please don't mind me. I am gonna create a bat file but not sure how to do that. Should i do touch solargraph.bat
?
Yes, create a file like normal and paste
@echo off
bash -c "/home/dikilikid/.rvm/gems/ruby-2.6.1/wrapper/solargraph %*"
Save the file somewhere simple and copy the file's location. Now open VSCode and open the command palette (ctrl+shift+p) and search "preferences: open settings (JSON)"
At the end of the settings.json file, add your bat file's path
"solargraph.commandPath": "C:\\solargraph.bat"
And restart VSCode afterwards.
It's giving me the error below. @mtam2
"solargraph.commandPath": "C:\\solargraph.bat"
C:\\solargraph.bat
to where you save the solargraph.bat fileThanks so much @mtam2 u saved me a lot of time! 😄 But on Ubuntu, solargraph is in /usr/local/bin/solargraph
and when I change bin
to wrapper
at solargraph.bat
like this
REM solargraph.bat
@echo off
bash -c "/usr/local/wrapper/solargraph %*"
vscode says
[Error - 21:53:56] Starting client failed
/bin/bash: /usr/local/wrapper/solargraph: No such file or directory
And when i leave bin
it works perfectly.
In your case using asdf, you must reshim your ruby.
asdf reshim ruby
After this, asdf will provide link to gem, then restart vscode.
There is a simpler solution than creating batch files that may not work depending on your setup.
Install Remote - WSL extension and start VS Code from your WSL with code .
inside the folder you have your project.
There is a simpler solution than creating batch files that may not work depending on your setup.
Install Remote - WSL extension and start VS Code from your WSL with
code .
inside the folder you have your project.
not working for me
@liciniomendes method works fine. Make sure you check your extensions because they will need to be installed again. You will see errors like below. Just press the "Install in WSL" button next to each extension you want to install. I had to do this for my Ruby plugins.
And here's an image showing it working:
I can ran solargraph when installed trough rubyinstaller, but I can't run it trough the wsl. Through the terminal (wsl) I'm using rbenv:
If just let
solargraph
as the command path inside VSCode, it ran inside the "rubyinstaller" version:If I try to set the:
I get:
Which, kind of makes sense since VSCode doesn't run from inside wsl.
Trough the windows command prompt is possible to run file from the wsl:
or...
Though, trying both
commandPath
, results in strange errors:Maybe it's possible to run solargraph trough bash trough the plugin internals?