Skip to content

Spaces in python interpreter path or program result in incorrectly quoted debugging commands with arguments #233

Description

@merely-present

Environment data

VS Code version: 1.86.2
Extension version: v2024.0.0
OS and version: Windows 10 Pro Up-to-date
Python version: 3.12
Shell: Powershell 7.4.1
Type of virtual environment used: venv with space in path.

Expected behaviour

The Python debugger should correctly quote paths that contain spaces in the Python interpreter path and the program to be debugged, ensuring commands are properly executed when arguments are taken through a launch.json configuration.

Actual behaviour

When there are spaces in the Python interpreter path or the program name, the debugger command fails due to improper quoting, leading to errors in execution.

For instance, if one's path for the interpreter were c:\Users\one\Documents\Python Folder\.venv\Scripts\python.exe, the error message they would receive would be

c:\Users\one\Documents\Python : The term 'c:\Users\one\Documents\Python' is not recognized as a name of a cmdlet, function, script file, or executable program.

Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Additional detail

Currently one can side step the program issue by using escaped quotes but I have not found a method to have the venv executables path be quoted correctly.

Steps to reproduce:

  • Create a Python file in a directory that has a space in its name.
  • Set up a virtual environment in a directory with a space in its name.
  • Configure launch.json to use the standard "Python Debugger: Current File with Arguments" like:
            {
                "name": "Python Debugger: Current File with Arguments",
                "type": "debugpy",
                "request": "launch",
                "program": "${file}",
                "console": "integratedTerminal",
                "args": "${command:pickArgs}"
            }
    
  • Start Debugging

Note: This also happens with manually hardcoded arguments.

Activity

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

Metadata

Metadata

Labels

bugIssue identified by VS Code Team member as probable bugneeds PRReady to be worked onverifiedVerification succeeded

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions