microsoft / debugpy

An implementation of the Debug Adapter Protocol for Python
https://pypi.org/project/debugpy/
Other
1.85k stars 137 forks source link

Specific characters in path of parent directories of file causes debugger to crash. #1671

Open RokeJulianLockhart opened 1 month ago

RokeJulianLockhart commented 1 month ago

Summary

I've managed to break the path parsing. Specifically, including certain characters in the parent directories of the file being debugged causes the debugger to crash.

I don't know what specific characters cause this, but I'll update the report when(/if) I do.

Reproduction

  1. Directory-Caused Crash

    The undermentioned path, which contains a normal filename (testfile.py) but an abnormally named immediate parent directory:

    /home/RokeJulianLockhart/Documents/  [-]    `{title: "Code",    id: ""}`{.JSON5}.dir/testfile.py

    ...causes ms-python.debugpy to crash:

    ```log RokeJulianLockhart@sayw4i:~/Documents$ cd /home/RokeJulianLockhart/Documents/\ \ \[-\]\`\{title:\ \"Code\",id:\ \"\"\}\`\{.JSON5\}.dir ; /usr/bin/env /usr/bin/python3 /home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 47225 -- /home/RokeJulianLockhart/Documents/\ \ \[-\]\`\{title:\ \"Code\",id:\ \"\"\}\`\{.JSON5\}.dir/testfile.py bash: cd: /home/RokeJulianLockhart/Documents/ [-]`{title: "Code",id: ""}`{.JSON5}.dir: No such file or directory Traceback (most recent call last): File "/usr/lib64/python3.12/runpy.py", line 198, in _run_module_as_main return _run_code(code, main_globals, None, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib64/python3.12/runpy.py", line 88, in _run_code exec(code, run_globals) File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 71, in cli.main() File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 486, in main run() File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 336, in run_file runpy.run_path(target, run_name="__main__") File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 320, in run_path code, fname = _get_code_from_file(run_name, path_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 289, in _get_code_from_file with io_open_code(decoded_path) as f: ^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: '/home/RokeJulianLockhart/Documents/ [-]`{title: "Code",id: ""}`{.JSON5}.dir/testfile.py' RokeJulianLockhart@sayw4i:~/Documents$ ```

    Merely one directory in the absolute path of the file need contain such characters for the parsing to fail, as the undermentioned "Terminal" log from ms-python.debugpy demonstrates:

    ```log RokeJulianLockhart@sayw4i:~/Documents$ cd /home/RokeJulianLockhart/Documents/\ \ \[-\]\`\{title:\ \"Code\",id:\ \"\"\}\`\{.JSON5\}.dir/test_directory ; /usr/bin/env /usr/bin/python3 /home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 47783 -- /home/RokeJulianLockhart/Documents/\ \ \[-\]\`\{title:\ \"Code\",id:\ \"\"\}\`\{.JSON5\}.dir/test_directory/test_file.py bash: cd: /home/RokeJulianLockhart/Documents/ [-]`{title: "Code",id: ""}`{.JSON5}.dir/test_directory: No such file or directory Traceback (most recent call last): File "/usr/lib64/python3.12/runpy.py", line 198, in _run_module_as_main return _run_code(code, main_globals, None, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib64/python3.12/runpy.py", line 88, in _run_code exec(code, run_globals) File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 71, in cli.main() File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 486, in main run() File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 336, in run_file runpy.run_path(target, run_name="__main__") File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 320, in run_path code, fname = _get_code_from_file(run_name, path_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 289, in _get_code_from_file with io_open_code(decoded_path) as f: ^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: '/home/RokeJulianLockhart/Documents/ [-]`{title: "Code",id: ""}`{.JSON5}.dir/test_directory/test_file.py' RokeJulianLockhart@sayw4i:~/Documents$ ```
  2. If I put the file deep enough (like [this example](https://gitlab.com/rokejulianlockhart/sg5n9q/-/blob/5ee5d9dddd190aa306092bdbec2bdf048196801f/%20%20%5B-%5D%09%60%7Btitle:%20%22Non-Metadata%22,%09id:%20%22s1gvg2%22%7D%60%7B.JSON5%7D.dir/%20%20%5B-%5D%09%60%7Btitle:%20%22Technical%22,%09id:%20%22s20cxw%22%7D%60%7B.JSON5%7D.dir/%20%20%5B-%5D%09%60%7Btitle:%20%22Applications%22,%09id:%20%22%22%7D%60%7B.JSON5%7D.dir/%20%20%5B-%5D%09%60%7Btitle:%20%22Configurator%22,%09id:%20%22s3wrcl%22%7D%60%7B.JSON5%7D.dir/%20%20%5B-%5D%09%60%7Btitle:%20%22Code%22,%09id:%20%22%22%7D%60%7B.JSON5%7D.dir/.%20%5B-%5D%09%60%60%7Btitle:%20%22%60platform.uname()%60%7B.Py%7D%20Field%20Output%22,%09id:%20%22sgskr5%22%7D%60%60%7B.JSON5%7D.txt.Py)) it completely breaks. Enter doesn't work because the path is incorrectly escaped, so ^C is necessary to exit the transient debug state:

    ```log RokeJulianLockhart@sayw4i:~/Software/Git/GitLab.com/RokeJulianLockhart/sg5n9q/ [-] `{title: "Non-Metadata", id: "s1gvg2"}`{.JSON5}.dir/ [-] `{title: "Technical", id: "s20cxw"}`{.JSON5}.dir/ [-] `{title: "Applications", id: ""}`{.JSON5}.dir/ [-] `{title: "Configurator", id: "s3wrcl"}`{.JSON5}.dir/ [-] `{title: "Code", id: ""}`{.JSON5}.dir$ cd /home/RokeJulianLockhart/Software/Git/GitLab.com/RokeJulianLockhart/sg5n9q/\ \ \[-]\ `\{title\:\ \"\`\{title:\ \"Non-Metadata\",id:\ \"s1gvg2\"\}\`\{.JSON5\}.dir/\ \ \[-\]\`\{title:\ \"Technical\",id:\ \"s20cxw\"\}\`\{.JSON5\}.dir/\ \ \[-\]\`\{title:\ \"Applications\",id:\ \"\"\}\`\{.JSON5\}.dir/\ \ \[-\]\`\{title:\ \"Configurator\",id:\ \"s3wrcl\"\}\`\{.JSON5\}.dir/\ \ \[-\]\`\{title:\ \"Code\",id:\ \"\"\}\`\{.JSON5\}.dir ; /usr/bin/env /usr/bin/python3 /home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 39897 -- /home/RokeJulianLockhart/Software/Git/GitLab.com/RokeJulianLockhart/sg5n9q/\ \ \[-\]\`\{title:\ \"Non-Metadata\",id:\ \"s1gvg2\"\}\`\{.JSON5\}.dir/\ \ \[-\]\`\{title:\ \"Technical\",id:\ \"s20cxw\"\}\`\{.JSON5\}.dir/\ \ \[-\]\`\{title:\ \"Applications\",id:\ \"\"\}\`\{.JSON5\}.dir/\ \ \[-\]\`\{title:\ \"Configurator\",id:\ \"s3wrcl\"\}\`\{.JSON5\}.dir/\ \ \[-\]\`\{title:\ \"Code\",id:\ \"\"\}\`\{.JSON5\}.dir/.\ \[-\]\`\`\{title:\ \"\`platform.uname\(\)\`\{.Py\}\ Field\ Output\",id:\ \"sgskr5\"\}\`\`\{.JSON5\}.txt.Py > > ^C RokeJulianLockhart@sayw4i:~/Software/Git/GitLab.com/RokeJulianLockhart/sg5n9q/ [-] `{title: "Non-Metadata", id: "s1gvg2"}`{.JSON5}.dir/ [-] `{title: "Technical", id: "s20cxw"}`{.JSON5}.dir/ [-] `{title: "Applications", id: ""}`{.JSON5}.dir/ [-] `{title: "Configurator", id: "s3wrcl"}`{.JSON5}.dir/ [-] `{title: "Code", id: ""}`{.JSON5}.dir$ ```

    This causes https://github.com/microsoft/debugpy/issues/1677 to occur:

    Screenshot_20240914_145708

  3. Debugger Functioning with Unusual Filename

    Note that this doesn't apply to the file's name. Consider the undermentioned example:

    /home/RokeJulianLockhart/Documents/. [-]    ``{title: "`platform.uname()`{.Py} Field Output",   id: "sgskr5"}``{.JSON5}.txt.Py

    As the undermentioned "Terminal" log demonstrates, it functions:

    ```log RokeJulianLockhart@sayw4i:~/Documents$ cd /home/RokeJulianLockhart/Documents ; /usr/bin/env /usr/bin/python3 /home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 38369 -- /home/RokeJulianLockhart/Documents/.\ \[-\]\ \`\`\{title\:\ \"\`platform.uname\(\)\`\{.Py\}\ Field\ Output\"\,\ id\:\ \"sgskr5\"\}\`\`\{.JSON5\}.txt.Py \`\`\{title:\ \"\`platform.uname\(\)\`\{.Py\}\ Field\ Output\",id:\ \"sgskr5\"\}\`\`\{.JSON5\}.txt.Py for k, v in platform_uname_as_dict.items() system = Linux node = sayw4i release = 6.10.10-200.fc40.x86_64 version = microsoft/vscode-python-debugger#1 SMP PREEMPT_DYNAMIC Thu Sep 12 18:26:09 UTC 2024 machine = x86_64 processor = RokeJulianLockhart@sayw4i:~/Documents$ ```

Environment

  1. Filename Character Support

    One must be using a filesystem and OS that support such characters. I use BTRFS on Fedora 40, but anything comparable (see https://en.wikipedia.org/w/index.php?title=Filename&oldid=1245592690#Comparison_of_filename_limitations) should work.

  2. Versions

    1. Code

      1. rpm -q 'code' 'code-insiders'
      2. code-1.93.1-1726079369.el8.x86_64
        code-insiders-1.94.0-1726207949.el8.x86_64
    2. Debugger

      https://marketplace.visualstudio.com/_apis/public/gallery/publishers/ms-python/vsextensions/debugpy/2024.11.2024082901/vspackage?targetPlatform=linux-x64 (from https://github.com/microsoft/vscode-python-debugger/releases/download/v2024.11.2024082901/extension.vsixmanifest).

Miscellaneous

Potentially related to https://github.com/microsoft/vscode-python-debugger/issues/233#issue-2152958262, although I doubt it, because /home/RokeJulianLockhart/Documents/Text File.txt.py works.

RokeJulianLockhart commented 1 month ago

https://github.com/microsoft/debugpy/issues/1671

In retrospect, apologies for the insane examples. Luckily, I've managed to reduce the character set necessary to reproduce it. Specifically, the undermentioned path:

[]`{:"",: ""}`{.}

...works:

```log RokeJulianLockhart@sayw4i:~/Documents/test_environment/[]`{:"",: ""}`{.}$ cd /home/RokeJulianLockhart/Documents/test_environment/\[\]\`\{:\"\",:\ \"\"\}\`\{.\} ; /usr/bin/env /usr/bin/python3 /home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 38487 -- /home/RokeJulianLockhart/Documents/test_environment/\[\]\`\{:\"\",:\ \"\"\}\`\{.\}/test_file.py for k, v in platform_uname_as_dict.items() system = Linux node = sayw4i release = 6.10.10-200.fc40.x86_64 version = microsoft/vscode-python-debugger#1 SMP PREEMPT_DYNAMIC Thu Sep 12 18:26:09 UTC 2024 machine = x86_64 processor = RokeJulianLockhart@sayw4i:~/Documents/test_environment/[]`{:"",: ""}`{.}$ ^C ```

...whereas the undermentioned path:

[]`{:"",    : ""}`{.}

...does not:

```log RokeJulianLockhart@sayw4i:~/Documents/test_environment/[]`{:"",: ""}`{.}$ cd /home/RokeJulianLockhart/Documents/test_environment/\[\]\`\{:\"\",:\ \"\"\}\`\{.\} ; /usr/bin/env /usr/bin/python3 /home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 59639 -- /home/RokeJulianLockhart/Documents/test_environment/\[\]\`\{:\"\",:\ \"\"\}\`\{.\}/test_file.py bash: cd: /home/RokeJulianLockhart/Documents/test_environment/[]`{:"",: ""}`{.}: No such file or directory Traceback (most recent call last): File "/usr/lib64/python3.12/runpy.py", line 198, in _run_module_as_main return _run_code(code, main_globals, None, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib64/python3.12/runpy.py", line 88, in _run_code exec(code, run_globals) File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 71, in cli.main() File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 486, in main run() File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 336, in run_file runpy.run_path(target, run_name="__main__") File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 320, in run_path code, fname = _get_code_from_file(run_name, path_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 289, in _get_code_from_file with io_open_code(decoded_path) as f: ^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: '/home/RokeJulianLockhart/Documents/test_environment/[]`{:"",: ""}`{.}/test_file.py' RokeJulianLockhart@sayw4i:~/Documents/test_environment/[]`{:"",: ""}`{.}$ ```

The sole difference is a single tab character, so it's a combination of the tab character and others which breaks parsing, because a directory name which is merely a tab ( ) does function, as the undermentioned log demonstrates:

```log RokeJulianLockhart@sayw4i:~/Documents/test_environment/[]`{:"",: ""}`{.}$ cd /home/RokeJulianLockhart/Documents/test_environment/\ / ; /usr/bin/env /usr/bin/python3 /home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024082901-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 51191 -- /home/RokeJulianLockhart/Documents/test_environment/\ //test_file.py for k, v in platform_uname_as_dict.items() system = Linux node = sayw4i release = 6.10.10-200.fc40.x86_64 version = microsoft/vscode-python-debugger#1 SMP PREEMPT_DYNAMIC Thu Sep 12 18:26:09 UTC 2024 machine = x86_64 processor = RokeJulianLockhart@sayw4i:~/Documents/test_environment/ $ ```
RokeJulianLockhart commented 1 month ago

https://github.com/microsoft/debugpy/issues/1671

Per https://github.com/microsoft/debugpy/issues/1677, I've attempted to collect some logs using this Stack Overflow answer.

Specifically, the aforereferenced most-compact-but-still-breaky path yet (undermentioned):

/home/RokeJulianLockhart/Documents/[]`{:"", : ""}`{.}/test_file.py

...produces the undermentioned logs in the "Extension Host" (non-"Worker") console:

```log 2024-09-14 15:38:08.145 [error] Error: Invalid debug adapter at kNt.p (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:509:95) at kNt.$acceptDAExit (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:509:35) at hat.S (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:2820:41484) at hat.Q (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:2820:41262) at hat.M (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:2820:40350) at hat.L (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:2820:39587) at fQ.value (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:2820:38248) at x.B (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:28:733) at x.fire (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:28:951) at A8.fire (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:527:10283) at l.onmessage (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:2831:11714) ```

However, [the aforementioned really-breaky-path](https://gitlab.com/rokejulianlockhart/sg5n9q/-/blob/5ee5d9dddd190aa306092bdbec2bdf048196801f/%20%20%5B-%5D%09%60%7Btitle:%20%22Non-Metadata%22,%09id:%20%22s1gvg2%22%7D%60%7B.JSON5%7D.dir/%20%20%5B-%5D%09%60%7Btitle:%20%22Technical%22,%09id:%20%22s20cxw%22%7D%60%7B.JSON5%7D.dir/%20%20%5B-%5D%09%60%7Btitle:%20%22Applications%22,%09id:%20%22%22%7D%60%7B.JSON5%7D.dir/%20%20%5B-%5D%09%60%7Btitle:%20%22Configurator%22,%09id:%20%22s3wrcl%22%7D%60%7B.JSON5%7D.dir/%20%20%5B-%5D%09%60%7Btitle:%20%22Code%22,%09id:%20%22%22%7D%60%7B.JSON5%7D.dir/.%20%5B-%5D%09%60%60%7Btitle:%20%22%60platform.uname()%60%7B.Py%7D%20Field%20Output%22,%09id:%20%22sgskr5%22%7D%60%60%7B.JSON5%7D.txt.Py) doesn't create any logs when ^C'd.

rchiodo commented 1 month ago

Looking at the other issue, we seem to translate tab characters into an escaped tab. I would guess that's the root cause of this issue.

debonte commented 1 month ago

I'm not seeing it escaped, but rather stripped out. It happens before the path is given to debugpy. Not sure if this is a vscode-python-debugger issue, a vscode issue, or what.

RokeJulianLockhart commented 1 month ago

https://github.com/microsoft/debugpy/issues/1671#issuecomment-2353436644

@rchiodo, indeed, it's the tabs. Working back from the right, I removed one character per test, and ascertained that []`{:"", works as a path:

```log RokeJulianLockhart@sayw4i:~/Documents/[]`{:"", : ""}`{.}$ cd /home/RokeJulianLockhart/Documents/\[\]\`\{:\"\", ; /usr/bin/env /usr/bin/python3 /home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024092501-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 37961 -- /home/RokeJulianLockhart/Documents/\[\]\`\{:\"\",/test_file.py test ```

...but []`{:"", doesn't:

```log RokeJulianLockhart@sayw4i:~/Documents/[]`{:"", : ""}`{.}$ cd /home/RokeJulianLockhart/Documents/\[\]\`\{:\"\", ; /usr/bin/env /usr/bin/python3 /home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024092501-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 37483 -- /home/RokeJulianLockhart/Documents/\[\]\`\{:\"\",/test_file.py bash: cd: /home/RokeJulianLockhart/Documents/[]`{:"",: No such file or directory Traceback (most recent call last): File "/usr/lib64/python3.12/runpy.py", line 198, in _run_module_as_main return _run_code(code, main_globals, None, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib64/python3.12/runpy.py", line 88, in _run_code exec(code, run_globals) File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024092501-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 71, in cli.main() File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024092501-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 501, in main run() File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024092501-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/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024092501-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/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024092501-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: '/home/RokeJulianLockhart/Documents/[]`{:"",/test_file.py' ```

...nor does merely :

```log RokeJulianLockhart@sayw4i:~/Documents/[]`{:"",$ cd /home/RokeJulianLockhart/Documents/ ; /usr/bin/env /usr/bin/python3 /home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024092501-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 35055 -- /home/RokeJulianLockhart/Documents//test_file.py Traceback (most recent call last): File "/usr/lib64/python3.12/runpy.py", line 198, in _run_module_as_main return _run_code(code, main_globals, None, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib64/python3.12/runpy.py", line 88, in _run_code exec(code, run_globals) File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024092501-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 71, in cli.main() File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024092501-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 501, in main run() File "/home/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024092501-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/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024092501-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/RokeJulianLockhart/.vscode-insiders/extensions/ms-python.debugpy-2024.11.2024092501-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: '/home/RokeJulianLockhart/Documents/test_file.py' ```

@debonte, that last log appears to corroberate your observation - /home/RokeJulianLockhart/Documents/test_file.py is definitely not the correct path. Impressively, it even redacted the empty /.

debonte commented 1 month ago

The tab appears to get stripped out between the point where we send the runInTerminal request and where the launcher is actually started. I believe it has something to do with runInTerminal's call to prepareCommand. I tried playing with argsCanBeInterpretedByShell, but the behavior was worse with it set to true.

When we send the runInTerminal request, the path to test_file.py is part of the args array and looks like this (note the \t):

'/home/erikd/issues/debugpy/1671/test/[]`\\{:"",\t: ""\\}`\\{.\\}/test_file.py'

But when the launcher is started, the path it receives from sys.argv is this (no \t):

'/home/erikd/issues/debugpy/1671/test/[]`\\{:"",: ""\\}`\\{.\\}/test_file.py'