-
Notifications
You must be signed in to change notification settings - Fork 96
Add support for Windows Subsystem Linux #156
Conversation
Add new "useWSL" launch attribute. When used, Bash on Windows will be used to launch runtimeExecutable. Source files directory mapping will also be automatically added.
@bzoz thanks a lot for the PR. I made a first review pass over the PR and here are some (high-level) comments:
Now I will try to make the PR run in the latest version of VS Code... /cc @roblourens |
I've rebased this PR on master: https://github.com/janeasystems/vscode-node-debug/tree/bartek-wsl-rb |
@bzoz please don't jump too quickly on my suggestions/questions. Today I played with "useWSL" and it worked great so far. Here is another finding/idea: I noticed that our version/protocol probing code in the But when thinking about this change in At the moment the extension.ts implements a command Here we could add the WSL logic: if BTW, in the August release we will deprecate the So, eventually the WSL logic would live in a node-debug has a DebugConfigurationProvider branch with a preview of "One more thing": more than one "DebugConfigurationProvider" can be registered for a debug type. So in theory it would be possible to have a "WSL" extension that adds the WSL logic to the node-debug extension... but this is probably way too ambitious ;-) |
I think that moving this to I think that adding something like "subsystemLinuxConsole" to the We could also separate the WSL detection and parameter mangling to a separate package and publish that. It would be easy for everyone to implement WSL support by themselves. VSCode could use this package too, in "subsystemLinuxConsole" implementation. |
Just to be clear: The only benefit is that the WSL code would be shared between the node-debug and node-debug2 adapters (because they are called from the But actually I tried to implement a transformation of a given launch config into a WSL launch config (without touching the DA) and this was harder than I thought (and I gave up for now). Then I looked into moving the "internalConsole" code into VS Code so that all three terminal types are handled on the VS Code side. But this turned out to be impossible because this code would have to move to VS Code as well (which would require the introduction of quite a few So moving the "internalConsole" to VS Code seems impractical (which is probably the reason why I didn't do this in the first place). This makes adding a "subsystemLinuxConsole" to the "runInTerminalRequest" less interesting because it does not cover all cases. With this I'm back at square one ;-) I like your suggestion to separate the WSL detection and parameter mangling. Initially it would be fine to only separate that logic into a separate file. Could you try to simplify/refactor your PR a bit:
|
Adding my 2cents to this, you'll probably also want to be able to load the environment variables configured in .bashrc when launching wsl e.g.: # ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac``` |
Refactored the code. Since the changes are significant, I've opened another PR: #158 |
Add a new
useWSL
boolean attribute to launch arguments. If set to true, debugger will launch Node.js (or givenruntimeExecutable
) using Windows Subsystem Linux.When the debugger is instructed to use Linux subsystem it will first test if it is installed. This is done by checking if
%WINDIR%\System32\bash.exe
(for 64-bit VS Code) or%WINDIR%\SYSNATIVE\bash.exe
(for 32-bit VS Code) is present. If found, it is then used asruntimeExecutable
, with user-specifiedruntimeExecutable
(with all appropriate parameters) passed as the command to execute (using bash-c
parameter). Mapping of the source filenames (thelocalRoot
andremoteRoot
attributes) is also automatically adjusted.For best results, this should be used together with
useWSL
implementation for theinspector
protocol (microsoft/vscode-node-debug2#126)/cc @yodurr