Skip to content

Support Rust toolchain from WSL #423

Open
@tyt2y3

Description

@tyt2y3

I am using rust inside Windows Subsystem for Linux (WSL).
It'd be great if I can use the same toolchain to perform syntax checking.
After some fiddling, I found some success. 2 things are concerned.

  1. finding the path to executable
  2. converting file paths from /mnt/c/ to C:\\

I made a dirty patch to rust_proc.py:

diff --git a/rust_proc.py.bak b/rust_proc.py
index 5d650d1..503ed3e 100755
--- a/rust_proc.py.bak
+++ b/rust_proc.py
@@ -212,6 +212,8 @@ class RustProc(object):
             # Prevent a console window from popping up.
             startupinfo = subprocess.STARTUPINFO()
             startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
+            self.cmd.insert(0, 'C:\\Windows\\System32\\wsl.exe')
+            self.cmd[1] = '/home/user/.cargo/bin/' + self.cmd[1]
             self.proc = subprocess.Popen(
                 self.cmd,
                 cwd=self.cwd,
@@ -298,6 +300,8 @@ class RustProc(object):
                 continue
             if self.decode_json and line.startswith('{'):
                 try:
+                    if sys.platform == 'win32':
+                        line = line.replace('/mnt/c/', 'C:\\\\')
                     result = json.loads(line)
                 except:
                     self.listener.on_error(self,

Now that syntax check is working. Not sure about other commands.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions