Skip to content
This repository has been archived by the owner on Nov 18, 2022. It is now read-only.

Possible to use this ext where rustup/rustc/cargo is provided by WSL? #144

Closed
kardeiz opened this issue Sep 8, 2017 · 11 comments
Closed

Comments

@kardeiz
Copy link

kardeiz commented Sep 8, 2017

Is it possible to use this extension on Windows, where VSCode is a Windows app, but where rustup/rustc/cargo/rls are provided through the Windows Subsystem for Linux (WSL) bash?

I've tried some naive things, like changing the integrated terminal and windowsExec to use bash, which works just fine, but the plugin keeps complaining "Couldn't start client Rust Language Server".

I also tried hardcoding rls.path to the path of RLS (installed via rustup on WSL bash).

Thanks!

@Xanewok
Copy link
Member

Xanewok commented Sep 8, 2017

Hm, piping stdio/stdout bash -c '<cmd>' does seem to work as per Windows Interoperability.

I believe microsoft/vscode#22663 might be relevant (as it gets into internals how language server processes are spawned)? I believe the issues it that node runtime in VSCode spawns processes naively using the same subsystem, which might be causing problems. It seems someone posted a workaround, could you try and see if it works?

@kardeiz
Copy link
Author

kardeiz commented Nov 21, 2017

Sorry, I just gave up on this for a while. If you are referring to the wsl-bash-tools wrapper mentioned in that thread, I tried that, but it doesn't work (and possibly doesn't quite address the issue of child process forking? This is mostly over my head).

I just discovered that it's possible to view the Chrome dev console in VSCode, which was a huge help.

I see in the warnings:

Error: Error running `rustc`: Error: spawnSync C:\Users\me\vscode_ext\wsl-bash-tools-master\wsl-bash-run.bat /home/me/.cargo/bin/rustup ENOENT
	at getSysroot

Then I see:

running C:\Users\me\vscode_ext\wsl-bash-tools-master\wsl-bash-run.bat /home/me/.cargo/bin/rls

And no further errors or output (and no IDE assistance when I edit an rs file) although the extension host crashes 30 seconds or so later.

Any thoughts?

@jonasbb
Copy link
Contributor

jonasbb commented Nov 22, 2017

Just an idea to establish connection between RLS and VS Code. I cannot test this as I don't use Windows. Can you run

nc -kl -e `which rls` 1234

in WSL. Under Windows you would then create a cmd file containing the equivalent of nc localhost 1234 and configure VS Code by setting the rls.path configuration to this cmd script.

Although, I am not sure if using RLS this way would work, even if the communication works. The reason is that RLS needs access to the files in the cargo project using the paths provided by the LSP client. Since the LSP client (VS Code) would use Windows paths but RLS would expect Linux paths this might be a problem.

The LSP (language server protocol) does not offer using a "remote" server in all cases, e.g., the LSP does not provide a way for the server to access files through the client. It would require a custom LSP extension to make this work. This also means that sandboxing LSP servers or running them on a remote machine is not simple.

@kardeiz
Copy link
Author

kardeiz commented Nov 22, 2017

I'm not sure exactly what that command is trying to do. which rls just outputs the path to rls, which is not a valid hostname.

Also, as far as I can tell, RLS does not run as an HTTP service, but rather as some kind of stdio loop service (not sure what to call this).

In any case, the output of that command in WSL is basically the same as it is on my CentOS box:

nc: getaddrinfo: Name or service not known

@jonasbb
Copy link
Contributor

jonasbb commented Nov 22, 2017

@kardeiz I forgot the -e parameter at first, Did you use that? The idea is just to pipe the stdio stuff through TCP to WSL, assuming TCP will work better than stdio.

The command should open netcat listening on port 1234 on localhost and execute rls (-e).

@kardeiz
Copy link
Author

kardeiz commented Nov 22, 2017

Oh, sorry, no, I wasn't familiar with using netcat as a server like that. Cool! Yes, that works.

@donaldpipowitch
Copy link

Hi, I'm quite new to the WSL. I'm not sure what "containing the equivalent of nc localhost 1234" should look like 🤔 Can someone explain this to me? Or is there an even better way to solve this available now?

Thank you.

@newtack
Copy link

newtack commented Jun 9, 2018

Any update on whether we can use WSL?

@yisonPylkita
Copy link
Contributor

@newtack There is a problem with filesystem paths mapping so you need to wait for GH-335

@yisonPylkita
Copy link
Contributor

yisonPylkita commented Mar 9, 2019

Since #488 was merged rls-vscode supports running vscode on Windows and rust, cargo, rustup.. on WSL.

@Xanewok Can you close this issue ?

@Xanewok
Copy link
Member

Xanewok commented Mar 9, 2019

Will do that, thanks for doing the triage!

@Xanewok Xanewok closed this as completed Mar 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants