Skip to content

Add optional injectRuntimeArgs flag to safely pass runtime args when interpreter path contains spaces #25539

@garrey-cyber

Description

@garrey-cyber

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" in launch.json works.
  • Dynamic runtime args break due to /usr/bin/env splitting 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"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions