Skip to content

[Windows][WSL2] Luanch debugger with node-terminal fails if cmd.exe is called in bashrc/zshrc in WSL2 #231050

Closed as not planned
@DanSM-5

Description

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version:
> code --version
1.94.2
384ff7382de624fb94dbaf6da11977bba1ecd427
x64
  • OS Version:

Windows 11

> Get-CimInstance Win32_OperatingSystem | Select-Object OSArchitecture, BuildNumber | FL

OSArchitecture : 64-bit
BuildNumber    : 22631

Steps to Reproduce:

  1. Call cmd.exe in bashrc or zshrc. E.g. cmd.exe /c "echo %USERPROFILE%".
  2. Create a launch.json of type node-terminal. Command doesn't matter as it won't be run.
        {
          "type": "node-terminal",
          "request": "launch",
          "name": "Debug",
          "command": "npm run start"
        },
  1. Go to Run and debug (ctrl-shift-d), search for Debug and click on the play button.

Expected result

Debugger open terminal and runs the command in launch.json to start the debugging session automatically. It should not stop by a call to cmd.exe.

Actual result

Debugger open terminal but shell remains in interactive mode waiting for user input. You can manually enter the command. A node/npm command will attach the debugger.

Recording of the issue

Code_15x4u0ShDU.mp4

Workarounds

Detect debug from vscode

Add an environment variable to detect debug from vscode and programatically prevent running any cmd.exe command.

        {
          "type": "node-terminal",
          "request": "launch",
          "name": "DEBUG",
          "env": {
            "VSCODE_DEBUG": "1"
          },
          "command": "npm run debug"
        },
# Then in bashrc/zshrc
if [ "$VSCODE_DEBUG" = 1 ]; then
  : nothing
else
 cmd.exe /c something
fi

Cons:

  • Additional environment variables that propagate on sub processes.
  • Dependant on the developer to implement the variable in their bashrc/zshrc

Use type node instead of node-terminal

Using type node in launch.json

        {
            "name": "Debug",
            "type": "node",
            "request": "launch",
            "runtimeVersion": "16.20.0",
            "runtimeExecutable": "npm",
            "runtimeArgs": ["run", "debug"]
        },

Cons:

  • Running scripts that launch other processes like docker compose up won't stop the containers when stop button is clicked.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

*out-of-scopePosted issue is not in scope of VS Code

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions