Fix debugger launch failure with spaces in interpreter path (regression from #964)#1015
Fix debugger launch failure with spaces in interpreter path (regression from #964)#1015ZA139 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Remove shell-style quoting of the interpreter executable when constructing DebugAdapterExecutable and add a comment explaining why (child_process.spawn is invoked without a shell and manual quotes become part of the filename causing ENOENT). Drop the fileToCommandArgumentForPythonExt import and update unit tests to expect unquoted interpreter paths for both default and custom debug adapter paths. References regressions reported in microsoft#1013 and analysis of microsoft#964.
| executable = fileToCommandArgumentForPythonExt(executable); | ||
| // DO NOT apply shell-style quoting here. | ||
| // The 'executable' path is passed to 'DebugAdapterExecutable', which internally | ||
| // uses 'child_process.spawn' in a non-shell environment. |
There was a problem hiding this comment.
Isn't this breaking the original fix in a shell environment? Seems like fileToCommandArgumentForPythonExt should have some way of checking how the launch is going to happen.
There was a problem hiding this comment.
Isn't this breaking the original fix in a shell environment? Seems like fileToCommandArgumentForPythonExt should have some way of checking how the launch is going to happen.
Yep, totally agreed — simply removing fileToCommandArgumentForPythonExt is not sufficient.
The correct fix should depend on whether spawn is running in a shell environment:
- If
options.shell === true, we need quotes to handle spaces correctly. - If
options.shell === false(default), we must avoid quotes to prevent ENOENT.
So instead of removing the helper entirely, we should update fileToCommandArgumentForPythonExt to accept a isShell flag and return the path accordingly.
There was a problem hiding this comment.
I'm not sure if it's a shell environment. It's just whether or not this command is a bat/cmd file.
https://github.com/microsoft/vscode/blob/main/src/vs/workbench/contrib/debug/node/debugAdapter.ts#L173-L180
So maybe this is the correct fix.
Problem
The debugger fails to start (ENOENT error) when the Python interpreter path contains spaces, such as
C:\Program Files\Python312\python.exe. This is a regression introduced in version 2026.4.0.Root Cause
PR #964 unconditionally applied shell-style quoting via
fileToCommandArgumentForPythonExt()to wrap the interpreter executable path before passing it toDebugAdapterExecutable.However,
DebugAdapterExecutableinternally useschild_process.spawn()in a non-shell environment. In this mode:"C:\...\python.exe"(including the quotes)ENOENT: file not foundSolution
Remove the shell-style quoting step for the executable path.
child_process.spawn()correctly handles spaces in paths via array-based argument passing and does not require manual quoting.Changes
fileToCommandArgumentForPythonExt(executable)call and replace with explanatory commentTesting
Related Issues