Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workspaceRoot invalid on Git Bash and WSL #24072

Closed
jdforsythe opened this issue Apr 6, 2017 · 3 comments
Closed

workspaceRoot invalid on Git Bash and WSL #24072

jdforsythe opened this issue Apr 6, 2017 · 3 comments
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues *duplicate Issue identified as a duplicate of another issue(s) WSL Issue when using WSL
Milestone

Comments

@jdforsythe
Copy link

jdforsythe commented Apr 6, 2017

  • VSCode Version: 1.11.0
  • OS Version: Windows 10

Steps to Reproduce:

  1. Set default shell to Git Bash or WSL (CTRL+SHIFT+P - "shell")
  2. Run a launch task using ${workspaceRoot}

Here's an example launch config:

{
  "name": "Debug All (node2)",
  "type": "node2",
  "request": "launch",
  "protocol": "inspector",
  "stopOnEntry": false,
  "args": [
    "--nolazy",
    "${workspaceRoot}/debugall.js"
  ],
  "cwd": "${workspaceRoot}/",
  "preLaunchTask": null,
  "runtimeExecutable": null,
  "env": {
    "NODE_ENV": "development"
  },
  "sourceMaps": false,
  "outDir": null,
  "console": "integratedTerminal",
  "skipFiles": [
    "<node_internals>/**",
    "**/node_modules/**"
  ]
},

Running this with the Powershell terminal works just fine. When running in WSL or Git Bash, the ${workspaceRoot} uses backslashes in the path and fails:

$ cd c:\dev\projectname/ ; env NODE_ENV=development node --inspect=32931
 --debug-brk --nolazy c:\dev\projectname/debugall.js
bash: cd: c:projectname/: No such file or directory
Debugger listening on port 32931.
Warning: This is an experimental feature and could change at any time.
To start debugging, open the following URL in Chrome:
    chrome-devtools://devtools/remote/serve_file/@60cd6e859b9f557d2312f5bf532f6aec5f284980/inspector.html?experiments=true&v8only=true&ws=localhost:32931/afb2c
73f-e645-4693-91bf-fc4b5a6364f8
Debugger attached.
module.js:471
    throw err;
    ^

Error: Cannot find module 'c:\dev\projectname\devprojectname\debugall.js'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Timeout.Module.runMain [as _onTimeout] (module.js:604:10)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)
Waiting for the debugger to disconnect...

Note that these commands will work in Git Bash if the backslashes are converted to the proper forward-slashes:

$ cd c:\dev\projectname
bash: cd: c:devprojectname: No such file or directory
$ cd c:/dev/projectname
[no error]
$ node c:/dev/projectname/debugall.js
[runs without error]

Converting the slashes doesn't fix WSL, though. In Git Bash the drives are mounted like /c/ for c:\. In WSL they're mounted at /mnt/c/, so it may require changing the drive part of ${workspaceRoot} depending on the shell you have selected. We could hard-code the workspace root, but that forces everyone to use a *nix based shell and have the project in the same path on their different machines.

@Tyriar Tyriar removed their assignment Apr 6, 2017
@Tyriar Tyriar added the debug Debug viewlet, configurations, breakpoints, adapter issues label Apr 6, 2017
@isidorn isidorn added the feature-request Request for new features or functionality label Apr 13, 2017
@isidorn isidorn added this to the Backlog milestone Apr 13, 2017
@isidorn isidorn removed their assignment Apr 13, 2017
@CherryDT
Copy link

CherryDT commented Apr 23, 2017

I tried the same thing and I did it using a script which converts the slashes for me and then launches node in WSL, but then of course VSCode doesn't understand the paths any longer. It is unfortunately not possible to specify a remoteRoot for launch actions (see my request #11681 a long time ago), so my workaround at the moment is to start the applications in the integrated console (which I have configured to open bash by default) using node --inspect --debug-brk server.js or similar, and then configuring a "WSL attach" action which has the remoteRoot set to /mnt/c/.../myProject. This way I can attach the VSCode debugger to the node instance running in WSL.

EDIT: Of course it would be best if the remoteRoot trick wouldn't be needed because it suffers from the same issue that it requires hardcoding the path which is a problem for us because it contains the username etc. - so we now have some projects where the VSCode debug config is .gitignored and some where it is actually needed in the repo for some reasons and there we now have multiple entries for different people's computer, which is not a good solution.

@weinand weinand added the WSL Issue when using WSL label Aug 16, 2017
@weinand weinand self-assigned this Aug 16, 2017
@weinand
Copy link
Contributor

weinand commented Aug 23, 2017

The title is misleading because the value of ${workspaceRoot} is perfectly fine and follows the spec. So there is nothing we could "fix".

The problem is that ${workspaceRoot} is being used in a context where backslashes in paths are not work they way they normally work in Windows.

In git/bash a command like node lib\app.js does not work because the backslash is not escaped (or the string is not quoted).

I've fixed that issue in #21635 by always quoting arguments that contain backslashes.

@CherryDT your issue/proposal is covered by this PR microsoft/vscode-node-debug#156

@weinand weinand added *duplicate Issue identified as a duplicate of another issue(s) and removed feature-request Request for new features or functionality labels Aug 23, 2017
@weinand
Copy link
Contributor

weinand commented Aug 23, 2017

duplicate of #21635

@weinand weinand closed this as completed Aug 23, 2017
@weinand weinand modified the milestones: August 2017, Backlog Aug 23, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues *duplicate Issue identified as a duplicate of another issue(s) WSL Issue when using WSL
Projects
None yet
Development

No branches or pull requests

5 participants