Search code examples
pythonvscode-extensionsvscode-debuggerdebugpy

Launching Python Debug with Arguments messes with file path


I'm using VSCode on Windows, with the GitBash as integrated terminal. When I launch the Python Debugger with default configurations, it works fine, and I get this command executed on the terminal:

/usr/bin/env c:\\Users\\augus\\.Apps\\anaconda3\\envs\\muskit-env\\python.exe \
c:\\Users\\augus\\.vscode\\extensions\\ms-python.debugpy-2024.2.0-win32-x64\\bundled\\libs\\debugpy\\adapter/../..\\debugpy\\launcher \
53684 -- E:\\muskit\\QuantumSoftwareTestingTools\\Muskit\\Muskit\\CommandMain.py

Notice the \\ in the file path. Again, above works just fine.

The problem is when I add the args property to my launch.json configuration.

launch.json

{
    "configurations": [
        {
            "name": "Python Debugger: Current File with Arguments",
            "type": "debugpy",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "args": "foo"
        }
    ]
}

The following command is executed on the terminal:

$  /usr/bin/env c:\Users\augus\.Apps\anaconda3\envs\muskit-env\python.exe \
c:\Users\augus\.vscode\extensions\ms-python.debugpy-2024.2.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher \
53805 -- E:\muskit\QuantumSoftwareTestingTools\Muskit\Muskit\CommandMain.py foo 
/usr/bin/env: ‘c:Usersaugus.Appsanaconda3envsmuskit-envpython.exe’: No such file or directory

Notice that, instead of \\. it uses \, which causes the "No such file or directory".

Is this a bug, or am I missing something?


Solution

  • Going through the issues on vscode-python repository, it is being mentioned in multiple issues that git bash is not officially supported. For example here:

    Note Gitbash isn't supported by Python extension, so use Select default profile to switch to cmd or powershell if need be.

    Possibly it is a bug and it will be better to use cmd or powershell, since you can run into issues in the future as well.

    Some related issues which mention the same