[Windows][WSL2] Luanch debugger with node-terminal fails if cmd.exe is called in bashrc/zshrc in WSL2 #231050
Closed as not planned
Closed as not planned
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:
- Call
cmd.exe
in bashrc or zshrc. E.g.cmd.exe /c "echo %USERPROFILE%"
. - 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"
},
- 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