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

SendText to terminal while handling run-in-terminal request send partial content. #158517

Closed
MSLeiter opened this issue Aug 17, 2022 · 14 comments
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug confirmation-pending debug Debug viewlet, configurations, breakpoints, adapter issues *duplicate Issue identified as a duplicate of another issue(s) terminal-input Relating to typing in the terminal not doing the right thing, IMEs not working, etc. windows VS Code on Windows issues
Milestone

Comments

@MSLeiter
Copy link

MSLeiter commented Aug 17, 2022

Type: Bug

Not sure the root cause, but with my setup, at least for Python files, there is an intermittent problem launching the debugger. Details:

NOTE: This has been happening intermittently for a long time, at least 6-9 months. Sometimes it's better, sometimes worse. Just haven't logged a defect because I can usually get it to launch within a few tries, but still very annoying.

  1. Launch a script from an open editor pane using the "debug" icon in the upper right (drop-down from the triangle "run" icon), or, alternately, use F5 shortcut to start debugging the file
  2. For Python extension, this launches a new "Python Debugger" terminal in my default "Git Bash" terminal environment.
  3. In the cases involved, I do have a virtual environment present which is being pointed to by the "Python: Select Interpreter" command so that it is activated in the terminal before the debug command is given.
  4. About half the time, the debug command fails to launch, apparently because not all characters cleanly got copied into the terminal to launch the debugger. The following is an example of a case where the space between "debugpy\launcher" and the number "58398" was missing, so it was searching for the file "launcher59358" instead of just "launcher" with the 59358 being an argument. Note that this is a typical error, and I've seen it fail in exactly this way (at that location), but I've also seen missing characters or other similar failures where all the characters for the command just aren't getting into the terminal correctly. In some cases the command doesn't get all the characters into the second prompt and a few "left over" characters get put onto the final prompt (where it should just be a clean prompt with no characters present).

Terminal output from "Python Debugger" terminal automatically opened when debugging:

<redacted> MINGW64 <path> (<branch>)
$ source <redacted_path>/.venv/Scripts/activate
(.venv)
<redacted> MINGW64 <path> (<branch>)
$  /usr/bin/env <redacted_path>\\.venv\\Scripts\\python.exe <redacted_path>\\.vscode\\extensions\\ms-python.python-2022.12.0\\pythonFiles\\lib\\python\\debugpy\\adapter/../..\\debugpy\\launcher59358 -- <redacted_path>\\.venv\\Scripts\\update_inc_ids 
<redacted_path>\AppData\Local\Programs\Python\Python37\python.exe: can't open file '<redacted_path>\.vscode\extensions\ms-python.python-2022.12.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher59358': [Errno 2] No such file or directory

Here's a 2nd example, where part of the prior command bled into the final prompt given back to the user. Note that the characters "env\Scripts\p" that were dumped on the final prompt appear to be missing from the middle of the command, where it says "\.envudate_inc_ids". They are also not just directly taken out of a chunk of the text, they are pulled out from multiple places - i.e. it should read "\.venv\Scripts\update_inc_ids", so the first v is missing completely, the en is duplicated both locations, then the \Scripts\ is moved, then p is from one character later, after the u. Also note that the "e" appears to be missing from "launcher" where it says "\debugpy\launchr", elsewhere in the text.

So, the text that is taken out is not just one chunk, but scrambled together from multiple places.

<redacted> MINGW64 <path> (<branch>)
$  cd c:\\code\\mca\\app_container_inspector ; /usr/bin/env <redacted path>\\.venv\\Scripts\\python.exe <redacted path>\\.vscode\\extensions\\ms-python.python-2022.12.0\\pythonFiles\\lib\\python\\debugpy\\adapter/../..\\debugpy\\launchr 60114 -- 
<redacted path>\\.envudate_inc_ids
C:\Users\mike.leiter\AppData\Local\Programs\Python\Python37\python.exe: can't open file 'c:\Users\mike.leiter\.vscode\extensions\ms-python.python-2022.12.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launchr': [Errno 2] No such file or directory
(.venv) 
<redacted> MINGW64 <path> (<branch>)
$ env\\Scripts\\p

Extension version: 2022.12.0
VS Code version: Code 1.70.1 (6d9b74a, 2022-08-10T06:08:33.642Z)
OS version: Windows_NT x64 10.0.19044
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i7-9850H CPU @ 2.60GHz (12 x 2592)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: unavailable_off
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 63.71GB (42.40GB free)
Process Argv --crash-reporter-id fe290e11-03c8-4ccb-a868-69e9db605c50
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492cf:30256860
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
pythondataviewer:30285071
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411cf:30542925
vsaa593cf:30376535
pythonvs932:30410667
wslgetstarted:30449410
cppdebug:30492333
pylanb8912:30545647
vsclangdf:30486550
c4g48928:30535728
hb751961:30543456
dsvsc012:30540252
azure-dev_surveyone:30548225

@MSLeiter
Copy link
Author

Note: I switched my default terminal from Git Bash to Command Prompt and it seems to be working okay and consistently (so far). So this may point to an issue sending text reliably to the Git Bash terminal.

@karthiknadig
Copy link
Member

@MSLeiter Git Bash is currently not supported, we have an open item to support it: microsoft/vscode-python#15799

@anthonykim1 anthonykim1 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 18, 2022
@MSLeiter
Copy link
Author

MSLeiter commented Aug 18, 2022

@karthiknadig The issue is that it does work, with these intermittent issues. For example, there are no path issues (Git Bash accepts mixed / and , as shown above).

There is no warning or error given anywhere that Git Bash is not supported.

Regardless, given the situation, this is additional information on what is needed to officially support Git Bash - there appears to be an interprocess communication issue with VS Code talking to Git Bash compared to other terminals, one where characters get added or missed. Somehow the buffer is not transferring characters cleanly.

@karthiknadig
Copy link
Member

karthiknadig commented Aug 18, 2022

This seems to be an issue with how run-in-terminal request passes the command to the terminal. Move this to core VS Code for further investigation since the request is handled by DAP Client.

@karthiknadig karthiknadig reopened this Aug 18, 2022
@karthiknadig karthiknadig changed the title Issue launching Debugger for Python script from debug icon in upper right toolstrip in editor pane SendText to terminal while handling run-in-terminal request send partial content. Aug 18, 2022
@karthiknadig karthiknadig transferred this issue from microsoft/vscode-python Aug 18, 2022
@VSCodeTriageBot
Copy link
Collaborator

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.70.2. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

@weinand weinand added the debug Debug viewlet, configurations, breakpoints, adapter issues label Aug 25, 2022
@roblourens
Copy link
Member

Dropping random characters would probably be an issue behind sendText itself, or an issue with git bash itself - any idea @Tyriar?

@MSLeiter
Copy link
Author

MSLeiter commented Aug 25, 2022

I had a peer try this out with Git Bash and he wasn't seeing the same issue - at least after several tries he didn't see it. The rest of our setups are pretty much the same. So, there may be something specific to my setup, but I'm not sure what that would be - maybe a specific extension I have loaded he doesn't, or a setting I changed in VS Code itself.

So, the root cause may be something to do with a particular install version, extension, or configuration setting. Maybe even in the Git for Windows install, etc., but all this is on the same vanilla Windows 10 install from IT for very similar work PCs, with basically all the same applications installed.

@parched
Copy link
Contributor

parched commented Aug 25, 2022

I have the exact same issue which has been occurring for a similar timeframe. I'll share all my versions and configurations to see if there's something in common.

@pjvanbeek
Copy link

I seem to be having the same issue. For me it is happening very frequently, basically every time I try to use the debugger, so it became useless. I have Git Bash as integrated terminal on Windows.

Version: 1.70.2 (user setup)
Commit: e4503b3
Date: 2022-08-16T05:35:13.448Z
Electron: 18.3.5
Chromium: 100.0.4896.160
Node.js: 16.13.2
V8: 10.0.139.17-electron.0
OS: Windows_NT x64 10.0.19044

@MSLeiter
Copy link
Author

I seem to be having the same issue. For me it is happening very frequently, basically every time I try to use the debugger, so it became useless. I have Git Bash as integrated terminal on Windows.

The temporary solution for me on Windows was to switch to either Cmd or PowerShell as the default terminal. Until Git Bash is officially supported it is unlikely this will be fixed. Debugging seems to work fine for me out of those shell, and I can open a separate Git Bash for anything else I want to do.

Note that swapping to cmd/PS also seems to fix the issue with both Run and Debug sometimes opening a new, separate, and duplicate terminal (name of "Python" for run and "Python Debug Console" for debugging). It now seems to always consistently reuse the existing window, if there was one.

@Tyriar
Copy link
Member

Tyriar commented Dec 2, 2022

We have had problems with sendText dropping characters in the past, maybe they're still present on git bash. In the meantime you can switch to just cmd or pwsh for debugging and tasks by making an automation profile via the terminal.integrated.automationProfile.windows setting.

@Tyriar Tyriar added windows VS Code on Windows issues confirmation-pending terminal-input Relating to typing in the terminal not doing the right thing, IMEs not working, etc. labels Dec 2, 2022
@Tyriar Tyriar added this to the Backlog milestone Dec 2, 2022
@Tyriar Tyriar added the bug Issue identified by VS Code Team member as probable bug label Dec 5, 2022
@LightCC
Copy link

LightCC commented Dec 9, 2022

@Tyriar The terminal.integrated.automationProfile.windows setting looks like a great option - do you have an example of how to fill out the parameters? It's not the same as the default profile setting that just takes the name of one of the existing profiles:

image

Do I just really need to set the path to the cmd.exe or powershell executable?

In fact, I can't figure out how to get to the various terminal settings for all the profiles to see the existing profiles - I remember there used to be a way to get there through the profile dropdown by the "create new terminal" + sign button, but it just takes you to settings now.

@Tyriar
Copy link
Member

Tyriar commented Dec 9, 2022

@LightCC here are the automation profile docs https://code.visualstudio.com/docs/terminal/profiles#_configuring-the-taskdebug-profile

You should still see a dropdown for profiles:

Screenshot 2022-12-09 at 12 42 00 pm

@Tyriar
Copy link
Member

Tyriar commented Dec 12, 2022

/duplicate #100225

@Tyriar Tyriar closed this as completed Dec 12, 2022
@VSCodeTriageBot VSCodeTriageBot added the *duplicate Issue identified as a duplicate of another issue(s) label Dec 12, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jan 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug confirmation-pending debug Debug viewlet, configurations, breakpoints, adapter issues *duplicate Issue identified as a duplicate of another issue(s) terminal-input Relating to typing in the terminal not doing the right thing, IMEs not working, etc. windows VS Code on Windows issues
Projects
None yet
Development

No branches or pull requests