-
Notifications
You must be signed in to change notification settings - Fork 822
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
Odd caret/cursor behavior in nano within SSH session #1436
Comments
I can also replicate this issue. It has been present since very early releases. |
Hm, very interesting. I cannot replicate this issue on the servers that I access regularly; I've never seen it before. I am currently trying to replicate it ssh'ing into an Ubuntu 16.04 server running Nano 2.5.3. I use ssh frequently, but mostly to systems running more-recent userspace tools. I wonder if the incompatibility isn't ssh; I wonder if the older version of nano does something that WSL doesn't support yet? |
Your remote terminfo might be defective? |
I just did a little more testing and confirmed that the issue is not present under Ubuntu 16.04.1 and nano 2.5.3. Perhaps it is an issue with older distros / editors aseering suggested. |
I just downloaded nano 1.3.12 from the CentOS archives and ran it locally on WSL. I was not able to reproduce this issue. So it must be a little more complicated than just "old nano binaries". |
@aseering you need to mask the ubuntu terminfo file with the centos one. |
@fpqc does that then reproduce the issue? Do you also need the old binary, or is it just the CentOS terminfo file? |
@aseering I haven't tested it but this sounds 100% like an incompatible terminfo file. |
I wasn't able to repro this with my Windows=14981->Ubuntu,nano=15.10, 2.4.2 ssh connection. Do we have a repro on a ssh to Ubuntu? Or is this only happening on connections to CentOS machines? |
I can confirm that the servers I SSH into when experiencing this error are running CentOS |
@ShimShamSam does it happen with 7.0? Also, on your CentOS instance, could you do me a favor and do this:
|
I get this behavior on Amazon EC2 instances running Amazon linux all the time: It does not happen on an older server running Debian 7.10: |
@CherryDT Again, could you do an infocmp in a broken terminal when you're ssh'd in? This sounds like a missing terminfo file. |
@fpqc CentOS release 6.7 (Final)
|
@ShimShamSam Yeah, I did a diff with the version I have on Arch, and it's a bit different. Here's the diff:
|
@fpqc , I'm not familiar with how terminfo files work. Any chance you could give a quick summary of what this means and what to do about it? (My initial interpretation is that these other platforms use different control sequences to perform some actions, in particular, sequences that the Windows console doesn't implement correctly yet?) Also, would it be correct/useful to pipe the output above through |
@aseering The control sequences tell the terminal or terminal emulator what to do and are specific to those pieces of hardware or software (possibly in different modes). Terminfo (and earlier Termcap) provide something like a translation layer that translates, for example, the control sequence to move the caret left or right to a specific control sequence for the terminal. This means an application writer can say "move the cursor left/right)", which then queries the terminfo for An old, outdated, or otherwise buggy or broken terminfo database will not match the controls with the correct control sequences and will therefore output and receive broken or even garbage controls. |
@fpqc -- thanks for the summary! I guess what I'm specifically looking for is, why would terminfo failures be relevant to WSL-specific display corruption? |
@aseering Because when you use |
@fpqc Ultimately this is an issue with WSL, right? |
@ShimShamSam I sort of doubt it, but it is highly complex and depends on the exact xterm mode that WSL is emulating (iirc xterm can emulate over 20 different physical terminals). Perhaps I could be wrong, but you have there that there is a material difference between the local and remote terminfo files. I had this exact problem when sshing into a FreeBSD VPS from a Linux box, and the problem was terminfo. Another possibility is that there is a failure to set modes (possibly due to an older breaking change with ncurses (ncurses4, ncurses5, and ncurses6 are all mutually binary incompatible, and WSL may only implement the newer sequences while ignoring the older ones)). |
@fpqc Git Bash on Windows works fine, as does PuTTY, so I'm inclined to think this should be the responsibility of WSL to fix. Furthermore, this primarily seems to happen in Nano, not Vim. |
@fpqc -- I agree with @ShimShamSam -- if I can ssh from an Ubuntu Linux machine into a CentOS server and it works fine (which seems to be the case for me), and I can ssh from WSL into a CentOS server and the terminal is corrupted (as is described here -- ditto for environments other than CentOS), then fundamentally this is something where WSL needs to fix itself to behave more like Ubuntu. As far as I'm concerned, the question is, exactly what does WSL need to do? |
@aseering Not having an affected centos instance to ssh into, I don't know. If it were a problem with WSL, we should see the behavior locally or when SSHing into a Centos7 instance at least. The fact that it is dependent on the distro of the remote machine makes it very odd and likely to be related to Terminfo. |
@fpqc @aseering @ShimShamSam I think to summarize what everyone's saying: I'd say it's highly unlikely that this is a problem with the WSL kernel itself, as this is code emitted from a remote machine not running the WSL kernel, so it could only really be a conhost problem. |
@zadjii-msft By "conhost", you mean "conhost.exe", right? If so, where should we report this bug? |
@ShimShamSam Zadjii is the guy who is going to go into the code and fix it. He's one of the programmers on the console/conhost team. Basically reporting this kind of thing, for now, is best done here. Eventually they will have their own repo. |
@ShimShamSam I crawled through those terminfos, and nothing looks particularly out of the ordinary or misconfigured. Does the behavior repro in Putty? It may be a bug with backspace itself. Does it only happen in nano, or are there other applications (vim, emacs) that the behavior also occurs in? |
I'm running into a similar issue again. Windows 10 build 14393, my apt packages are up-to-date within the Linux subsystem. Nano works fine when used locally, but when I SSH to an up-to-date Debian stable box with Nano 2.7.4, if I hold down an arrow key to scroll through a long file, it will seemingly randomly write A, B, C, or D into the file, depending on which arrow key I'm holding. I've tries launching Bash through cmd and through ConEmu, and both exhibit this issue, even after switching ConEmu between XTerm and AppKeys escape sequences. When I SSH to this server using Putty, I do not get this issue. Since I don't experience the issue with nano locally, and I don't experience the issue when using Putty, it looks like the issue must be with how WSL handles the SSH connection. None of the solutions above my comment help (the two commands directly above my comment, and updating the terminfo on the remote host). |
Hi @ianling -- build 14393 contains the very first public-beta release of WSL; it has gone through several major releases and a lot of console bugfixes since then. Would you be willing to update to the latest stable Windows release (build 16299, I believe) through Windows Update? And try again, see if it resolves the issue for you. |
I figured that was probably the issue when I noticed I was on 14393. It's a corporate environment and I don't manage WSUS here, so I'm probably out of luck unfortunately. Thanks for the response! |
So this issue is actually with CentOS/RHEL then it seems, not WSL correct? I'm experiencing it when SSH'ing into a RHEL 7.4 server that's fully updated via yum. It only impacts nano, not console, vi, or anywhere else. Sounds like the solution is downloading a new terminfo source and merging it in - which I'll have to script on all our Linux servers. |
And to follow up, I did the following on an impacted RHEL 7.4 server, exited the ssh session, exited the WSL window, reconnected and it still is doing the cursor thing. Does the remote server need to be restarted or sshd restarted after applying the terminfo update? wget http://invisible-island.net/datafiles/current/terminfo.src.gz |
https://serverfault.com/questions/329154/ssh-garbling-characters-in-vim-nano-on-remote-server |
Thanks for the discussion. Closing this issue since:
If you have further asks/issues, please file new issues on our Console GitHub Repo. |
Here's the workaround I'm using. Place this function at the end of your ~/.profile to automatically run these commands on any server you ssh into...
You could also try using the RemoteCommand ssh_config directive, but some servers may not support it. Just remember that if you want to use the ssh command to setup a tunnel or do anything other than start a terminal session, you'll want to run the ssh binary with the full path to bypass this function (i.e. /usr/bin/ssh). |
I was really hoping the sane thing would help Sam-Hall. It didn't for me :( Using nano with the malfunction as described in this issue is serious. Please fix soon. |
I've found that running "export TERM=linux" before running Nano helps a lot more than the "stty sane" command. I really think this issue is a problem with Nano as the link posted by @NothingWeAre suggests. |
This seems to be heart of my problem - microsoft/terminal#214 |
No promises, but this might be related to microsoft/terminal#283 actually. While we only recently regressed this for Ubuntu et al, it might shed some light on this thread as well, as the symptoms seem to be incredibly similar. |
Okay, I've finally gotten some time to try and look at this. I've got a CentOS 7.6 VM. (admittedly, there's a coloration bug I'm working on in another branch currently that's causing the header/footer to be the wrong color, but that's unrelated) |
Hi try the following copy and past these 3 lines Sat Dec 1 13:04:59 2018 +1300 doh move cursor to line 3, left arrow once to get to end of line 2, hit backspace for me the cursor end up at beginning of line |
All I can say for a fact is that I work with a lot of RHEL servers, versions 6 and 7 mostly. Without the workaround I can consistently reproduce the issue by opening a text file with many lines of text, they don't have to be particularly long lines. Navigating around the file using cursor keys, page up/down and home and end for a bit, then use the cursor left from the beginning of a line to end up at the end of a longish line of text, then backspace a few times and the bug is reproduced. Since creating an alias for my ssh command that immediately applies "stty sane; export TERM=linux;" I've not experienced the issue. Since it takes a few years for such obscure bugs to get fixed upstream and then a few years later for the fixes to work their way into all the various distros, I'm pretty sure I'm going going to have to get comfortable with this workaround for now. |
Thas part does nothing (or at least, shouldn't). Your
That part is, unfortunately, not WSL actionable. WSL does not control your Follow microsoft/terminal#283 and hope for the best. It only flipped to fix-inbound two days ago and hasn't even hit the street yet. |
@nitrologic Out of curiosity, what about that particular selection of text made you think that nano would be broken for that text, while fixed in the case I previously demonstrated? There was another internal bug that I would say was pretty similar to this one. I determined the fix for that one was checked in about 2 weeks ago. It's on it's way to Insider's now, so it'll probably first be available around Christmas/New Years, depending on how fast code moves over the holidays. |
@zadjii-msft with recent update to 1803 (build 17134.471) I am no longer suffering from this issue. Hurrah! |
I'm still suffering from that case, I do have to point out this didn't happen on Debian system i sshed into. I tried to update the terminfo according to the wget command, but it didn't help Would love to hear anyone's thoughts or help about it. |
Was fixed now broken again :) |
Yet Another Workaround for those of us stuck on on old build: add this to the end of your local
|
I have this issue using ConEmu on Windows 10 when I start |
@cawoodm There was actually another issue that was also causing troubles with ssh & centos, and likely also caused problems in ConEmu. I'd refer back to microsoft/terminal#1825, which tracked the upstream issue. It should be resolved in the next Windows release |
@rymo fixed it for me with ConEmu - thumbs up! |
My 2 penneth, for information sake; I had to add Thanks to who actually gave this valuable answer, it's been a frustration for years on my device! |
This did it for me. Thanks a lot. |
Started worked with Windows Server Core and use OpenSSH as it works nice now. But with need of an editor and already use nano on mac and linux I loved to use nano here as well. So I installed using choco install nano but sadly found out that cursor movement do not work properly here (Using Terminal from Mac in a ssh session). I tried to add
But getting error for RemoteCommand as export is not compatible on Windows Servers. |
A brief description
When SSH'd into a server and editing a file in nano, moving the caret around with the arrow keys or deleting text is buggy. I've attached a gif below demonstrating the issue.
This does not happen if you're not SSH'd into a server, giving me reason to believe this something to do with the way SSH state is managed.
A corresponding Uservoice suggestion already exists.
Expected results
The caret should move around as expected
Actual results (with terminal output if applicable)
The caret moves all over the place.
Your Windows build number
14971
Steps / All commands required to reproduce the error from a brand new installation
SSH into a server
Create a file with the following lines of text:
This is a test.
I'm going to press backspace to delete this text.
Open the file in nano
Move the caret to the end of the file
Press and hold backspace
The text was updated successfully, but these errors were encountered: