Skip to content

Debugger doesn't quote paths with spaces #767

Closed as not planned
Closed as not planned

Description

Before creating a new issue, please check the FAQ to see if your question is answered there.

Environment data

  • debugpy version: 2025.10.0
  • OS and version: Ubuntu Linux 22.04.1 LTS
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.13.5
  • Using VS Code or Visual Studio: VS Code
    Version: 1.102.3
    Commit: 488a1f239235055e34e673291fb8d8c810886f81
    Date: 2025-07-29T03:00:23.339Z
    Electron: 35.6.0
    ElectronBuildId: 11847422
    Chromium: 134.0.6998.205
    Node.js: 22.15.1
    V8: 13.4.114.21-electron.0
    OS: Linux x64 6.8.0-72-generic

Actual behavior

Debugpy cannot handle spaces in folder names

 /usr/bin/env /bin/python /home/cory/.vscode/extensions/ms-python.debugpy-2025.10.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 45117 -- /nfs/twilightsparkle.cory.albrecht.name/mnt/Archives/home/cory/Development/The Planet Monger/utilities/src/taps-query.py ${command:pickArgs} 
cory@redbarchetta[17:02:38].../Development/The Planet Monger/utilities$  /usr/bin/env /bin/python /home/cory/.vscode/extensions/ms-python.debugpy-2025.10.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 45117 -- /nfs/twilightsparkle.cory.albrecht.name/mnt/Archives/home/cory/Development/The Planet Monger/utilities/src/taps-query.py ${command:pickArgs} 
Traceback (most recent call last):
  File "/usr/lib/python3.13/runpy.py", line 198, in _run_module_as_main
    return _run_code(code, main_globals, None,
                     "__main__", mod_spec)
  File "/usr/lib/python3.13/runpy.py", line 88, in _run_code
    exec(code, run_globals)
    ~~~~^^^^^^^^^^^^^^^^^^^
  File "/home/cory/.vscode/extensions/ms-python.debugpy-2025.10.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 71, in <module>
    cli.main()
    ~~~~~~~~^^
  File "/home/cory/.vscode/extensions/ms-python.debugpy-2025.10.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 501, in main
    run()
    ~~~^^
  File "/home/cory/.vscode/extensions/ms-python.debugpy-2025.10.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 351, in run_file
    runpy.run_path(target, run_name="__main__")
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cory/.vscode/extensions/ms-python.debugpy-2025.10.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 309, in run_path
    code, fname = _get_code_from_file(run_name, path_name)
                  ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "/home/cory/.vscode/extensions/ms-python.debugpy-2025.10.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 278, in _get_code_from_file
    with io_open_code(decoded_path) as f:
         ~~~~~~~~~~~~^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/nfs/twilightsparkle.cory.albrecht.name/mnt/Archives/home/cory/Development/The'

Expected behaviour

That debugpy properly handle valid path names, like escaping spaces the way the soon-to-be retired "type": "python" in launch.json.

cory@redbarchetta[16:28:15].../Development/The Planet Monger/utilities$  /usr/bin/env /nfs/twilightsparkle.cory.albrecht.name/mnt/Archives/home/cory/Development/The\ Planet\ Monger/utilities/.venv/bin/python /home/cory/.vscode/extensions/ms-python.debugpy-2025.10.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 39967 -- /nfs/twilightsparkle.cory.albrecht.name/mnt/Archives/home/cory/Development/The\ Planet\ Monger/utilities/src/taps-query.py 
Connecting to TAP service at https://simbad.u-strasbg.fr/simbad/sim-tap/...
Attempting login...

Steps to reproduce:

  1. Make a python project in a directory that has spaces in the path.
  2. Try to debug with VScode using "type": "debugpy" in launch.json.
  3. Watch it fail.

Activity

  1. rchiodo commented on Aug 5, 2025

    @rchiodo
    Contributor

    This should be a bug in the vscode-python-debugger extension. It needs to wrap the command line arguments in quotes (debugpy can't guess that the space is from a directory)

    Transferring issue.

  2. changed the title [-]Debugpy can't handle paces in path names[/-] [+]Debugger doesn't quote paths with spaces[/+] on Aug 5, 2025
  3. CoryAlbrecht commented on Aug 6, 2025

    @CoryAlbrecht
    Author

    Same basic thing as microsoft/debugpy#1980 perhaps? Both have to do with vscode-python-debugger not understanding spaces, but that one is under Windows instead of Linux.

    Also, #233 seems to be the same problem, though there was a bunch of misunderstanding by some people as to what the problem was.

    Based on #233 I did a little bit of testing.

    {
      "version": "0.2.0",
      "configurations": [
        {
          "name": "Python Debugger: Current File with Arguments",
          "type": "debugpy",
          "request": "launch",
          "program": "${file}",
          "console": "integratedTerminal",
          // "args": "${command:pickArgs}",
          "cwd": "${workspaceFolder}"
        }
      ]
    }

    That version of launch.json works:

    (.venv) cory@redbarchetta[15:38:35]~/Development/The Planet Monger/utilities$  cd /home/cory/Development/The\ Planet\ Monger/utilities ; /usr/bin/env /home/cory/Development/The\ Planet\ Monger/utilities/.venv/bin/python /home/cory/.vscode/extensions/ms-python.debugpy-2025.10.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 40817 -- /home/cory/Development/The\ Planet\ Monger/utilities/src/taps-query.py 
    

    But uncomment that "args" line:

    {
      "version": "0.2.0",
      "configurations": [
        {
          "name": "Python Debugger: Current File with Arguments",
          "type": "debugpy",
          "request": "launch",
          "program": "${file}",
          "console": "integratedTerminal",
          "args": "${command:pickArgs}",
          "cwd": "${workspaceFolder}"
        }
      ]
    }

    like that and the problem occurs whether you choose to enter any args

    (.venv) cory@redbarchetta[15:45:48]~/Development/The Planet Monger/utilities$  /usr/bin/env /home/cory/Development/The Planet Monger/utilities/.venv/bin/python /home/cory/.vscode/extensions/ms-python.debugpy-2025.10.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 58221 -- /home/cory/Development/The Planet Monger/utilities/src/taps-query.py --env .env.simbad 
    /usr/bin/env: ‘/home/cory/Development/The’: No such file or directory
    

    or not

    (.venv) cory@redbarchetta[15:44:11]~/Development/The Planet Monger/utilities$  cd /home/cory/Development/The\ Planet\ Monger/utilities ; /usr/bin/env /home/cory/Development/The Planet Monger/utilities/.venv/bin/python /home/cory/.vscode/extensions/ms-python.debugpy-2025.10.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 43817 -- /home/cory/Development/The Planet Monger/utilities/src/taps-query.py  
    /usr/bin/env: ‘/home/cory/Development/The’: No such file or directory
    

    But if you go an put the pickArgs in []s like "args" expects for mimicking multiple args on a command line:

    {
      "version": "0.2.0",
      "configurations": [
        {
          "name": "Python Debugger: Current File with Arguments",
          "type": "debugpy",
          "request": "launch",
          "program": "${file}",
          "console": "integratedTerminal",
          "args": ["${command:pickArgs}"],
          "cwd": "${workspaceFolder}"
        }
      ]
    }

    Then the spaces in the script path get properly escaped but your args are also escaped, rendering the utility of ${command:pickArgs} for Python script debugging non-existent.

    (.venv) cory@redbarchetta[15:49:21]~/Development/The Planet Monger/utilities$  cd /home/cory/Development/The\ Planet\ Monger/utilities ; /usr/bin/env /home/cory/Development/The\ Planet\ Monger/utilities/.venv/bin/python /home/cory/.vscode/extensions/ms-python.debugpy-2025.10.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 54935 -- /home/cory/Development/The\ Planet\ Monger/utilities/src/taps-query.py --env\ .env.simbad 
    [2025-08-06 15:50:29.006112] Taps-Query starting up.
    usage: taps-query.py [-h] [-f ENV]
    taps-query.py: error: unrecognized arguments: --env .env.simbad
    

    So whatever string-mashing vscode-python-debugger is doing before running a command line to start debugging, it appears to depend on what it sees as the value of the "args" parameter from launch.json.

    I hope that helps narrow things down. :-)

  4. eleanorjboyd commented on Aug 14, 2025

    @eleanorjboyd
    Contributor

    Hi! If you uninstall the python environments extension does that fix the problem? We have an outstanding issue I am fixing regarding the envs extension causing this for others

  5. github-actions commented on Sep 14, 2025

    @github-actions

    Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off.

    Happy Coding!

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

Metadata

Metadata

Labels

info-neededIssue requires more information from postertriage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions