-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Problem
When using the Python debugger in VS Code, if the Python interpreter path contains spaces (e.g., under macOS iCloud paths), passing runtime arguments dynamically (via the debug toolbar or tasks) causes the debugger launch to fail: e.g.: env: /Volumes/.../Daemon: No such file or directory
- Launching with no arguments works.
- Static
"args"inlaunch.jsonworks. - Dynamic runtime args break due to
/usr/bin/envsplitting the interpreter path at spaces.
Proposed enhancement
Add an optional boolean flag in launch.json:
"injectRuntimeArgs": true
Behavior:
Default (false) → current deterministic behavior.
true → any runtime arguments passed from the debug toolbar, command palette, or tasks are automatically appended (or optionally replace) the "args" array at launch.
Uses VS Code’s list-based launch to avoid shell splitting issues.
Benefits
- Avoids /usr/bin/env path splitting bug for spaces in interpreter or program paths.
- Runtime arguments behave exactly like static "args".
- Default behavior remains unchanged.
- Works with multi-root workspaces and tasks.
Optional Enhancement
Optionally allow a mode to control whether runtime args append or replace:
"injectRuntimeArgsMode": "append" | "replace"
Example
{
"name": "Python: Debug with dynamic args",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/my_script.py",
"args": ["--logfile", "file.log"],
"injectRuntimeArgs": true,
"console": "integratedTerminal"
}