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

Unable to debug with integrated terminal (WSL) #50445

Closed
ADBurpitt opened this issue May 25, 2018 · 17 comments
Closed

Unable to debug with integrated terminal (WSL) #50445

ADBurpitt opened this issue May 25, 2018 · 17 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded WSL Issue when using WSL
Milestone

Comments

@ADBurpitt
Copy link

  • VSCode Version: 1.23.1 & 1.24.0-insider
  • OS Version: Windows 10 - 1803

Steps to Reproduce:

  1. Create a node launch config
  2. Run with console set to "integratedTerminal"

This then launches a new integrated terminal, and executes the following:

➜ cd c:\Code\debug && node --inspect-brk=30756

Which in my case is invalid due to the initial cd c:\Code\debug, as I am using wsl:

cd: no such file or directory: c:Codedebug

I am aware of the previous issues involving this being closed as the problem was fixed, however this no longer seems to be the case.

Sample config:

    {
        "type": "node",
        "request": "launch",
        "name": "Launch Program",
        "console": "integratedTerminal",
    }
@roblourens
Copy link
Member

Have you tried "useWSL": true?

@roblourens roblourens added the info-needed Issue requires more information from poster label May 29, 2018
@ADBurpitt
Copy link
Author

Yes, this changes what is executed in the terminal to:

➜ cd c:\Code\debug && C:\WINDOWS\System32\bash.exe -ic "node --inspect-brk=48993"

So it attempts to run the node process using bash.exe, which shouldn't be necessary as it is doing that from within wsl to begin with, so just executing node should work.

Either way as far as I can tell this isn't really relevant as the first statement cd c:\Code\debug is unchanged, the part that executes node is never reached due to the use of \ instead of / in the cd statement.

Although the useWSL option actually also uses \, in addition to using an incorrect path to bash.exe.
The following executes node correctly:

mnt/c/Windows/System32/bash.exe -ic "node"

So it seems useWSL just compounds the issue.

It should make no difference to running bash.exe, but just in case my integrated terminal is running zsh via wsl.exe, with the following user setting:

"terminal.integrated.shell.windows": "C:\\Windows\\System32\\wsl.exe",

Which works as the backslashes are escaped unlike in the statements VSCode attempts to execute.

@roblourens
Copy link
Member

Ok, I guess it's assuming that your terminal is not already in WSL. @weinand do you know if this case should work?

As a workaround, what if you remove useWSL and set "cwd": "/path/to/project" so it doesn't take the windows-style path?

@ADBurpitt
Copy link
Author

This doesn't seem to be allowed:

"Attribute 'cwd' is not absolute ('mnt/c/Code/debug'); consider adding '${workspaceFolder}/' as a prefix to make it absolute."

And when I run it with any variation of "cwd": "${workspaceFolder}" it just has the same output as previously.

@lfurzewaddock
Copy link

I recently created a VS Code extension: WSL workspaceFolder, which may help.

@roblourens roblourens added bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues and removed info-needed Issue requires more information from poster labels Sep 13, 2018
@adityawibisana
Copy link

Hi @lfurzewaddock, your extension works on mine. Thanks a lot!!

@weinand weinand added the WSL Issue when using WSL label Nov 21, 2018
@weinand weinand assigned weinand and unassigned roblourens Nov 21, 2018
@ltomes
Copy link

ltomes commented Dec 10, 2018

@adityawibisana What does your debug launch configuration look like in the end?

@virgilwashere
Copy link

@adityawibisana What does your debug launch configuration look like in the end?

        {
            "type": "node",
            "request": "launch",
            "name": "Run NPM script in WSL",

            "useWSL": true,
            "localRoot": "${workspaceFolder}",
            "remoteRoot": "${command:extension.vscode-wsl-workspaceFolder}",
            "runtimeExecutable": "npm",
            "runtimeArgs": [
                "run-script",
                "foo",
            ],
            "internalConsoleOptions": "openOnSessionStart",
            "skipFiles": [
                "<node_internals>/**/*.js",
            ],
        },

Borrowed shamelessly from @n0v1 in #54593

@adityawibisana
Copy link

adityawibisana commented Dec 28, 2018

@ltomes and @virgilwashere : first I need the extension, and it is working. Turn out that it is working without extension too. Last config:

{
            "name": "WSL fix remoteRoot",
            "type": "node",
            "request": "attach",            
            "address": "localhost",
            "port": 5858,
            "sourceMaps": false,
            "localRoot": "${workspaceFolder}",
            "remoteRoot": "/mnt/d/Projects/yourAwesomeProject" 
}

On my case, most important part is the remoteRoot, which should point to your corresponding folder.

Do note that this one is attach, so you need to manually node debug app.js your project first

@rozzzly
Copy link

rozzzly commented Jan 7, 2019

I'd like to add to @adityawibisana's comment:

[...] you need to manually npm start your project first

This makes the assumption that your package.json contains something like:

"scripts": {
	"start": "node --inspect-brk ./dist/index.js"
}

What's key is that your launch a node process with the --inspect/--inspect-brk set.

@adityawibisana
Copy link

adityawibisana commented Jan 7, 2019

@rozzzly : No, my package.json:

"scripts": {
    "start": "node app.js",

edited: I did
node debug app.js, instead of npm start. And then, yap, pressing the play button on VS code

@rozzzly
Copy link

rozzzly commented Jan 8, 2019

@adityawibisana

node debug app.js might work for you right now, per Node.js Foundation website

The legacy debugger has been deprecated as of Node 7.7.0. Please use --inspect and Inspector instead.
[...]
The V8 Debugging Protocol is no longer maintained or documented.

That was 2 years ago. Unless you have a specific reason to use v7/the old protocol, using --inspect/--inspect-brk is advisable as they are two different mechanisms, not just an alias.

Also the port for --inspect/--inspect-brk defaults to 9229 not 5858 like the old debugger. If your launch config specifies that the port to be used is 5858, you'd need to specify that when spawning the process as well. --inspect=5858/--inspect-brk=5858

Hopefully that clears up any confusion for a visitor from google in a year or two. 😉

@adityawibisana
Copy link

@rozzzly : 💯 That was using node v5, anyway :)

@Tyriar Tyriar added this to the April 2019 milestone May 2, 2019
@Tyriar
Copy link
Member

Tyriar commented May 2, 2019

We just announced remote development with VS Code, check out the blog post for details https://code.visualstudio.com/blogs/2019/05/02/remote-development

@Tyriar Tyriar closed this as completed May 2, 2019
@miguelsolorio miguelsolorio added the verified Verification succeeded label May 7, 2019
@filetvignon
Copy link

filetvignon commented May 29, 2019

I'm having the same problem in the original post: cd: no such file or directory: c:Codedebug
It also uses 'bash.exe' instead of 'wsl.exe'.

However, it works if I don't use the option "console": "integratedTerminal".

I've installed the recent Remote WSL extension and it works in the WSL remote window, even with "console": "integratedTerminal". But not on a regular window.

This is my launch configuration:
{
"type": "node",
"request": "launch",
"name": "nodemon WSL",
"runtimeExecutable": "nodemon",
"program": "${workspaceFolder}/server.js",
"restart": true,
"protocol": "inspector",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"useWSL": true
}

@Tyriar
Copy link
Member

Tyriar commented May 30, 2019

@filetvignon the WSL extension is the solution to the problem, you cannot do it in a normal window by design.

@weinand
Copy link
Contributor

weinand commented May 30, 2019

Please remove the "useWSL": true option.

@vscodebot vscodebot bot locked and limited conversation to collaborators Jun 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded WSL Issue when using WSL
Projects
None yet
Development

No branches or pull requests