Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown characters were output in the built-in terminal. #302

Closed
ZhanZiyuan opened this issue Apr 5, 2024 · 12 comments
Closed

Unknown characters were output in the built-in terminal. #302

ZhanZiyuan opened this issue Apr 5, 2024 · 12 comments
Assignees
Labels
triage-needed Needs assignment to the proper sub-team

Comments

@ZhanZiyuan
Copy link

ZhanZiyuan commented Apr 5, 2024

Behaviour

Debug a Python file C:\Users\user\Downloads\test.py in Visual Studio Code.

Steps to reproduce:

  1. Open C:\Users\user\Downloads\test.py in Visual Studio Code.

  2. Press F5.

  3. The built-in terminal launched.

  4. The output is printed, while it looks strange:

    & 'D:\Python\python.exe' 'c:\Users\user\.vscode\extensions\ms-python.python-2024.4.0\python_files\lib\python\debugpy\adapter/../..\debugpy\launcher' '55162' '--' 'C:\Users\user\Downloads\test.py' 
    y' ;f32e748c-078e-4722-b78a-88d04fc76110y' ;f32e748c-078e-4722-b78a-88d04fc761107.098666746304519
  5. However, if the Python file is run in the terminal instead of being debugged with Visual Studio Code, the issue will not occur:

    ❯ python C:\Users\user\Downloads\test.py
    7.098666746304519

Diagnostic data

launch.json configuration

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: 当前文件",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": true
        },
        {
            "name": "C/C++: gcc.exe 生成和调试活动文件",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "D:\\mingw64\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "将反汇编风格设置为 Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: gcc.exe 生成活动文件"
        }
    ]
}

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

2024-04-05 20:11:01.495 [info] DAP Server launched with command: D:\Python\python.exe c:\Users\user\.vscode\extensions\ms-python.python-2024.4.0\python_files\lib\python\debugpy\adapter
2024-04-05 20:11:03.265 [info] Send text to terminal:  & 'D:\Python\python.exe' 'c:\Users\user\.vscode\extensions\ms-python.python-2024.4.0\python_files\lib\python\debugpy\adapter/../..\debugpy\launcher' '55037' '--' 'C:\Users\user\Downloads\test.py' 

Output for Python Debugger in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python Debugger)

Nothing.

2024-04-05_20-52-08

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Apr 5, 2024
@karthiknadig
Copy link
Member

karthiknadig commented Apr 5, 2024

@ZhanZiyuan Can you share logs from Output > Python? this seems like it might be coming from python extension trying to activate the environment.

@ZhanZiyuan
Copy link
Author

@ZhanZiyuan Can you share logs from Output > Python? this seems like it might be coming from python extension trying to activate the environment.

OK. Here are logs from Output > Python:

Output for Python in the Output panel

Contents in brackets were translated by Google Translate.

2024-04-06 09:09:48.404 [info] 试验“pythonRecommendTensorboardExt”处于活动状态 (Test "pythonRecommendTensorboardExt" is active)
2024-04-06 09:09:48.404 [info] 试验“pythonREPLSmartSend”处于活动状态 (Test "pythonREPLSmartSend" is active)
2024-04-06 09:09:48.404 [info] 试验“pythonTerminalEnvVarActivation”处于活动状态 (Test "pythonTerminalEnvVarActivation" is active)
2024-04-06 09:09:48.404 [info] 试验“pythonTestAdapter”处于活动状态 (Test "pythonTestAdapter" is active)
2024-04-06 09:09:48.404 [info] Default formatter is set to ms-python.black-formatter for workspace d:\zigzag\Python Assignments
2024-04-06 09:09:48.404 [info] Default formatter is set to ms-python.black-formatter for workspace d:\zigzag\postgraduate\curricula\computational chemistry\assignments
2024-04-06 09:09:48.404 [info] Test server listening.
2024-04-06 09:09:48.404 [info] Python 解释器路径: D:\Python\python.exe (Python interpreter path: D:\Python\python.exe)
2024-04-06 09:09:51.325 [info] > conda info --json
2024-04-06 09:09:51.327 [info] DAP Server launched with command: D:\Python\python.exe c:\Users\user\.vscode\extensions\ms-python.python-2024.4.0\python_files\lib\python\debugpy\adapter
2024-04-06 09:09:55.800 [info] 正在启动 Pylance 语言服务器。 (Launching Pylance language server.)
2024-04-06 09:10:37.285 [info] > ~\.conda\Scripts\conda.exe info --json
2024-04-06 09:10:37.380 [info] > ~\.condarc\Scripts\conda.exe info --json
2024-04-06 09:10:37.469 [info] > D:\Miniconda3\Scripts\conda.exe info --json
2024-04-06 09:10:37.810 [info] > hatch env show --json
2024-04-06 09:10:37.810 [info] cwd: D:\zigzag\Python Assignments
2024-04-06 09:10:37.810 [info] > hatch env show --json
2024-04-06 09:10:37.810 [info] cwd: D:\zigzag\postgraduate\curricula\computational chemistry\assignments
2024-04-06 09:10:37.830 [info] > D:\Python\python.exe -I ~\.vscode\extensions\ms-python.python-2024.4.0\python_files\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2024.4.0\python_files\interpreterInfo.py
2024-04-06 09:11:32.259 [info] Send text to terminal:  & 'D:\Python\python.exe' 'c:\Users\user\.vscode\extensions\ms-python.python-2024.4.0\python_files\lib\python\debugpy\adapter/../..\debugpy\launcher' '61783' '--' 'C:\Users\user\Downloads\test.py' 
2024-04-06 09:13:34.460 [info] DAP Server launched with command: D:\Python\python.exe c:\Users\user\.vscode\extensions\ms-python.python-2024.4.0\python_files\lib\python\debugpy\adapter
2024-04-06 09:13:35.019 [info] Send text to terminal: �
2024-04-06 09:13:35.019 [info] Send text to terminal:  d:; cd 'd:\zigzag\Python Assignments'; & 'D:\Python\python.exe' 'c:\Users\user\.vscode\extensions\ms-python.python-2024.4.0\python_files\lib\python\debugpy\adapter/../..\debugpy\launcher' '62042' '--' 'C:\Users\user\Downloads\test.py' 

I found that when switching between Output and Terminal, what's printed in Terminal occasionally becomes normal:

Incorrect output in the built-in terminal
❯  d:; cd 'd:\zigzag\Python Assignments'; & 'D:\Python\python.exe' 'c:\Users\user\.vscode\extensions\ms-python.python-2024.4.0\python_files\lib\python\debugpy\adapter/../..\debugpy\launcher' '62282' '--' 'C:\Users\user\Downloads\test.py'
2' '--' 'C:\x5cUsers\x5cuser\x5cDownloads\x5ctest.py' ;d089afb6-7948-4b04-9449-756ef89608562' '--' 'C:\x5cUsers\x5cuser\x5cDownloads\x5ctest.py' ;d089afb6-7948-4b04-9449-756ef89608567.098666746304519
Correct output in the built-in terminal
❯  d:; cd 'd:\zigzag\Python Assignments'; & 'D:\Python\python.exe' 'c:\Users\user\.vscode\extensions\ms-python.python-2024.4.0\python_files\lib\python\debugpy\adapter/../..\debugpy\launcher' '62042' '--' 'C:\Users\user\Downloads\test.py'
7.098666746304519

@veroneoriginal
Copy link

Good afternoon! I have the same problem.
When running the script, the "c" character gets into the terminal, then an error occurs and then the script is executed.
shot_240406_142435

@ferihegedus
Copy link

ferihegedus commented Apr 10, 2024

I have the same problem. Some additional info: for the first time that the "Python Debug Console" terminal window is launched, the script is started and the debug session works. However, if I want to debug again, it does not work in Git Bash, and behaves strangely in PowerShell.

Output in GitBash
First try:
image

Second try:
image

Output in PowerShell
First try:
image

Second try:
image

EDIT:
There are no issues with version 1.87.2.

@karthiknadig
Copy link
Member

@Tyriar This looks like it might be coming from shell integration.

@Tyriar
Copy link
Member

Tyriar commented Apr 12, 2024

@karthiknadig that guid could be the set command line nonce if it's not something the extension is inputting 🤔

@ZhanZiyuan what version of Windows are you on?

@ZhanZiyuan
Copy link
Author

@karthiknadig that guid could be the set command line nonce if it's not something the extension is inputting 🤔

@ZhanZiyuan what version of Windows are you on?

Hello. My OS Version: Windows 10.0.19045

I'm also using the latest stable release of Visual Studio Code (version 1.88).

@Tyriar
Copy link
Member

Tyriar commented Apr 12, 2024

This is likely a very old version of conpty misbehaving as it's shipped with Windows and you're still on 10. So a workaround is to disable shell integration, the real fix is to update to Windows 11.

@ZhanZiyuan
Copy link
Author

This is likely a very old version of conpty misbehaving as it's shipped with Windows and you're still on 10. So a workaround is to disable shell integration, the real fix is to update to Windows 11.

Alright, many thanks for your reply though the computer is not eligible to upgrade to Windows 11.

@ferihegedus
Copy link

ferihegedus commented Apr 22, 2024

This is likely a very old version of conpty misbehaving as it's shipped with Windows and you're still on 10. So a workaround is to disable shell integration, the real fix is to update to Windows 11.

I have this problem on Windows 11 as well. However it might be independent of the Python Debugger itself, as there are no issues with VsCode version 1.87.2, only with 1.88.

The problem is only present when using "console": "integratedTerminal".

@yezy98
Copy link

yezy98 commented May 1, 2024

I have encountered similar issue when I update to VSC 1.88.1 and it is solved when I revert to 1.87.2
When I debug a Python file, for the first time, everything works normally. However, if I restart it or stop and debug again, it goes wrong. Although from the Outoput, I can see the command text is sent to Terminal, there is no text shown on the Terminal. Seconds later, a TimeOut error raised.

Another walkaround is setting "console" as "internal Console" in launch.json

My Windows version is 22631.3527

I have another PC with a Windows Canary Insider Preview 26200.5001
And VSC 1.88.1 works well.

@paulacamargo25
Copy link
Contributor

Closing the issue as the error is on vscode side.

@paulacamargo25 paulacamargo25 closed this as not planned Won't fix, can't repro, duplicate, stale May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

7 participants