Skip to content

debugpy does not quote spaces in command line arguments. #820

Open

Description

@YLivay

Issue

When calling debugpy from command line using the vscode integrated terminal, it does not quote command line arguments.

I saw some similar issues (#767) but these were focused on launching the debugger using launch.json. This issue is about calling debugpy from the terminal.

How to reproduce

import sys
print(f"First arg is: '{sys.argv[1]}'")
print(f"Second arg is: '{sys.argv[2]}'") # should print 'hello world'

In a vscode terminal:

$ debugpy /path/to/script.py hi "hello world"
First arg is: 'hi'
Second arg is: 'hello'

Conclusion

This seems to be caused by a wrapper script this extension ships.

$ which debugpy
~/.vscode/extensions/ms-python.debugpy-2025.10.0-linux-x64/bundled/scripts/noConfigScripts/debugpy

which has:

#! /bin/bash
# Bash script
export DEBUGPY_ADAPTER_ENDPOINTS=$VSCODE_DEBUGPY_ADAPTER_ENDPOINTS
python3 $BUNDLED_DEBUGPY_PATH --listen 0 --wait-for-client $@

The actual command this script ended up executing is:

$ python3 /path/to/.vscode/extensions/ms-python.debugpy-2025.10.0-linux-x64/bundled/libs/debugpy --listen 0 --wait-for-client path/to/script.py hi hello world

As a workaround i changed that wrapper script to use "$@" instead of $@. I'm not sure if this is the correct fix for everyone but worked for my humble usecase :)

Activity

  1. eleanorjboyd commented on Oct 3, 2025

    @eleanorjboyd
    Contributor

    So this is specifically for no-config debugging?

  2. YLivay commented on Oct 4, 2025

    @YLivay
    Author

    So this is specifically for no-config debugging?

    Yes. This is specifically when using the debugpy wrapper script bundled with the vscode-python-debugger extension.

  3. github-actions commented on Nov 4, 2025

    @github-actions

    Hey Eleanor Boyd (@eleanorjboyd), this issue might need further attention.

    Yariv (@YLivay), you can help us out by closing this issue if the problem no longer exists, or adding more information.

  4. YLivay commented on Nov 4, 2025

    @YLivay
    Author

    Hey, yeah this issue still exists. Every time the extension updates I manually reapply the fix.

  5. github-actions commented on Dec 5, 2025

    @github-actions

    Hey Eleanor Boyd (@eleanorjboyd), this issue might need further attention.

    Yariv (@YLivay), you can help us out by closing this issue if the problem no longer exists, or adding more information.

  6. J17359 commented on Dec 16, 2025

    @J17359

    I'm seeing the same issue as Yariv (@YLivay). Their double quote workaround works for me as well.

    VSCode: 1.107.0
    Python Debugger Extension: 2025.16.0

  7. eleanorjboyd commented on Dec 16, 2025

    @eleanorjboyd
    Contributor

    Hi! Please give this a try now - we made some updates the quoting logic

  8. J17359 commented on Dec 16, 2025

    @J17359

    Eleanor Boyd (@eleanorjboyd) which version of this plugin am I looking to install to make sure this works?

  9. eleanorjboyd commented on Dec 17, 2025

    @eleanorjboyd
    Contributor

    can you try the debugger extension version 2025.18.0 it would use the right debugpy version as a result

  10. J17359 commented on Dec 17, 2025

    @J17359

    I can't upload an image from my work PC but I updated my extension, confirmed via which debugpy that I'm pointing at the 2025.18.0 version, and inspected that file. No double quotes around the $@. And confirmed that my args that have a space fail to be parsed properly by debugpy without my performing the workaround defined above.

    So still seems broken to me.

  11. eleanorjboyd commented on Dec 17, 2025

    @eleanorjboyd
    Contributor

    Thanks for checking - Rich Chiodo (@rchiodo) maybe this is the next item to tackle in line with the other spacing updates you just made?

  12. rchiodo commented on Dec 17, 2025

    @rchiodo
    Contributor

    I think the fix to the problem is what the user specified? (no fix necessary in debugpy) $@ should be quoted. Is there a script for every terminal type? That would be the only hard part. Determining the quote string if there isn't a per terminal script.

  13. vs-code-engineering commented on Dec 25, 2025

    @vs-code-engineering

    This issue has been closed as it has been labeled with info-needed and has not received the additional information that was requested from the issue author. It has been labeled as info-needed for 7 days.

  14. YLivay commented on Dec 25, 2025

    @YLivay
    Author

    sorry, i didnt feel the need to add additional comment to Michael Steppe (@J17359) and Rich Chiodo (@rchiodo) . the shell script is still not quoted and the fix should not be in debugpy but the wrapper script shipped with the vscode extension specifically.

    i think the fix i suggested makes sense, at the very least for bash.

    please reopen the issue

  15. bernd-wechner commented on Apr 30, 2026

    @bernd-wechner

    I will add that if the directory for the project contains spaces in the path that the Python debugger fails to run. Silently. I lost a half day's productivity just working that out so am in a foul mood.

    Reality of this is noted, and hopefully remembers ere I waste any more time on it.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage-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