8000 Paste limited to 50 chars when run in Docker container on Windows · Issue #460 · PowerShell/PSReadLine · GitHub
[go: up one dir, main page]

Skip to content

Paste limited to 50 chars when run in Docker container on Windows #460

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

Closed
SteveL-MSFT opened this issue Oct 26, 2016 · 20 comments
Closed

Paste limited to 50 chars when run in Docker container on Windows #460

SteveL-MSFT opened this issue Oct 26, 2016 · 20 comments

Comments

@SteveL-MSFT
Copy link
Member

docker run --rm -it microsoft/windowsservercore powershell

Copy 12345678901234567890123456789012345678901234567890hello
Paste that into the powershell window

Expected: entire string to be pasted
Actual: 'hello' is cut off

Removing PSReadline and paste works as expected

@SteveL-MSFT
Copy link
Member Author

TFS:9535413

@StefanScherer
Copy link
StefanScherer commented Feb 8, 2017

Is there any progress on this topic? I tried latest PowerShell alpha to validate, but ran into #492

@StefanScherer
Copy link

I have seen that PowerShell 6 beta is out. Is there any update for this?
Current Docker image microsoft/windowsservercore:10.0.14393.1198 still has this problem.

@dhirschfeld
Copy link
dhirschfeld commented Jun 19, 2017

This makes the powershell on windowsservercore pretty unusable!

@daghb
Copy link
daghb commented Nov 2, 2017

Please fix, this is really annoying

@jstarks
Copy link
Contributor
jstarks commented Nov 3, 2017

Agreed that this is annoying. We're hoping to improve the console API compatibility in windowsservercore in the next Windows release, which I suspect will resolve this and several other issues. Currently I don't have any plans to debug this with the current set of images, unfortunately.

@StefanScherer
Copy link

@daghb If you really need this feature now you can do this with a workaround commented in moby/moby#29646 (comment)

docker build -t pastable/windowsservercore https://raw.githubusercontent.com/StefanScherer/dockerfiles-windows/master/powershell-50-characters/Dockerfile
docker run -it pastable/windowsservercore powershell

@lzybkr
Copy link
Contributor
lzybkr commented Nov 4, 2017

As this is likely a containers issue - there is nothing I can do in PSReadLine, so I'm closing this issue. If it turns out that's incorrect - @jstarks will let me know and we'll reopen this issue.

@lzybkr lzybkr closed this as completed Nov 4, 2017
@StefanScherer
Copy link

I just tried the PowerShell 6 RC image on a Windows Server 2016, version 1709 with

docker run -it microsoft/powershell:6.0.0-rc-nanoserver-1709

and - oh my dear - even here I can reproduce the 50 char paste problem, both from a Mac Docker client as well as directly from the Windows Server machine:

powershell-6-rc-50-chars-paste-problem

Now we have the situation that it does not work for both windowsservercore and nanoserver.

So how can we proceed to get this fixed?
As you can see this is really annoying trying out some PowerShell commands in an isolated environment.

@StefanScherer
Copy link

I also can reproduce the same problem in Windows Server Insider 17035 build.

@StefanScherer
Copy link
StefanScherer commented Nov 18, 2017

Using the PowerShell 6.0.0-rc without the PSReadLine module works fine in Insider nanoserver 17035 container. OK, no colors, but pasting a 877 char long command just works fine. So I cannot imagine that this is a problem inside Windows and we have to wait for RS3. :-)

@lzybkr
Copy link
Contributor
lzybkr commented Nov 20, 2017

I can reproduce this problem without PSReadLine, I can even reproduce it in cmd. Paste the following:

echo 0
echo 12345678901234567890123456789012345678901234567890hello
echo 2

Note - 3 lines, not 1. The text hello is not pasted on the second line, and the third line is never executed:

#1 PS> docker run --rm -it microsoft/windowsservercore cmd
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

C:\>echo 0
0

C:\>echo 12345678901234567890123456789012345678901234
12345678901234567890123456789012345678901234

C:\>exit

It's possible people don't see this problem w/o PSReadLine because no single line is > 50 characters, but if there was, things probably won't work as expected.

@StefanScherer
Copy link
StefanScherer commented Nov 20, 2017

OK, thanks @lzybkr I can repro this in my environment.
But I tried this just before (echo 3000 chars) and this works fine in cmd.

echo 1                                                 2                                                 3                                                 4                                                 5                                                 6                                                 7                                                 8                                                 9                                                 10                                                11                                                12                                                13                                                14                                                15                                                16                                                17                                                18                                                19                                                20                                                21                                                22                                                23                                                24                                                25                                                26                                                27                                                28                                                29                                                30                                                31                                                32                                                33                                                34                                                35                                                36                                                37                                                38                                                39                                                40                                                41                                                42                                                43                                                44                                                45                                                46                                                47                                                48                                                49                                                50                                                51                                                52                                                53                                                54                                                55                                                56                                                57                                                58                                                59                                                60                                                

So it's the kind how to read console input in PSReadLine that amplifies the effect. Agreed that something between docker CLI and the cmd in Container stops sending further if the process inside the container reads a little bit, then does something else (cmd executes the first echo) then wants to read more...

Interesting that pasting that command in a powershell does not stop at 50 chars but receives some more fragments. My repeatable results look like this:

PS C:\> echo 1
           22                          42
1
22
42

Removing PSReadLine from microsoft/nanoserver:6.0.0-rc-nanoserver-1709 makes this single line work for me as well in pwsh, but your three line example also stops in the second line. Really weird effect :-)

@lzybkr
Copy link
Contributor
lzybkr commented Nov 20, 2017

My theory - and actually how I came up with my example - is that if you are on cooked input mode, the paste works perfectly for everything up to the first newline. In cooked mode, it makes sense to not simulate keyboard input if possible - in other words, not generate an INPUT_RECORD for each character.

After Enter (newline), conhost knows it is exiting cooked input mode, and must generate an INPUT_RECORD for the remaining input in case some other console application wants to consume that input, which may be consumed via cooked input or raw input.

Normally I suggest using Ctrl+v to paste because it is faster and provides a more reliable experience, but with containers I think that's never an option - the host and container shouldn't be sharing clipboards.

At any rate, I think it's obvious there's nothing I can do to fix this in PSReadLine, but if someone finds a workaround, then that'd be great.

@bverkron
Copy link
bverkron commented Oct 22, 2019

Still no fix for this? I did try this workaround here but that repo does not seem to exist anymore and the second command on it's own doesn't work.

#460 (comment)

@dhirschfeld
Copy link

Pretty sure it works in Windows 2019 or later

@janheindejong
Copy link

I'm also running into this... any progress?

@lzybkr
Copy link
Contributor
lzybkr commented Mar 18, 2020

@janheindejong - you haven't provided any details like which OS you're hitting the problem.

Based on microsoft/terminal#38 it seems like this was fixed - though one comment says it reproduces in 1809.

Maybe @jstarks remembers which release has the fix.

@ng-anton
Copy link

I also have this problem. Windows 10 Pro 1909 with Powershell 7.0.0. Docker for Windows with Docker Engine v19.03.8 running Running Powershell 5.1.14393.1944.

@henriqueholtz
Copy link

I also have this problem with the image mcr.microsoft.com/windows/servercore/iis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants
0