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

Add support for Windows Subsystem Linux #158

Merged
merged 1 commit into from
Sep 18, 2017

Conversation

bzoz
Copy link
Contributor

@bzoz bzoz commented Aug 29, 2017

Continued from #156.

Refactored the code to a separate file and kept the code changes to the minimum. Per @nelak suggestion now we use bash -ic.

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.
@noinkling
Copy link

noinkling commented Oct 6, 2017

Not sure if this is the correct place to ask, but how do I use something like the node_modules/.bin/babel-node executable instead of node?

I've tried all the combinations I can think of for runtimeExecutable and all I get are messages like Attribute 'runtimeExecutable' does not exist (when it's a Windows path), and Cannot find runtime '...../node_modules/.bin/babel-node' on PATH (when it's a WSL path).

I could install babel-node globally so it's in my PATH, but that's not recommended and is a pain to remember to update.

Edit: Actually it looks like this might be to do with the fact that babel-node is a symlink (I'm using yarn if it matters) not recognized properly by Windows.

Edit 2: If I turn it into a proper file I get a little further, however a new issue crops up:

Debugging with inspector protocol because a runtime executable is set.
c:\Dev\Projects\my-project/node_modules/.bin/babel-node --inspect=19380 --debug-brk src\server\index.js 
Node process error: Error: spawn c:\Dev\Projects\my-project\node_modules\.bin\babel-node ENOENT

That shouldn't have a Windows path should it? But using a WSL path in for runtimeExecutable just gives the other error I already mentioned.

If I run the equivalent with a relative path within a WSL terminal like:

$ node_modules/.bin/babel-node --inspect=19380 --debug-brk src\server\index.js
Debugger listening on ws://127.0.0.1:19380/4e50a4f8-39e7-4a8c-bd2a-ab513e0c91c4
...

you can see it works fine.

launch.json config:

{
  "type": "node",
  "request": "launch",
  "name": "Launch Server",
  "useWSL": true,
  "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/babel-node",
  "program": "${workspaceFolder}/src/server/index.js"
}

@bzoz
Copy link
Contributor Author

bzoz commented Oct 9, 2017

@noinkling try this:

{
  "type": "node",
  "request": "launch",
  "name": "Launch Program",
  "useWSL": true,
  "program": "${workspaceFolder}/src/server/index.js",
  "protocol": "legacy",
  "runtimeExecutable": "./node_modules/.bin/babel-node"
}

When you specify runtimeExecutable, the inspector protocol will be used. It does not support WSL just yet, it is still WIP, so you have to explicitly use legacy protocol.

The ${workspaceFolder} will contain Windows-like path separator. This was fixed recently, see microsoft/vscode#35249.

@noinkling
Copy link

Thanks, it seems I missed the

for this milestone "legacy" protocol only

disclaimer in the release notes (or maybe it was added later?). I'm using Node 8 so the legacy protocol isn't an option, guess I'll just have to wait a little longer.

leotulipan added a commit to leotulipan/wp2md that referenced this pull request Oct 15, 2017
@alanosman
Copy link

YES! It's in the latest production release. Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants