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

Progress indicator broken on Alacritty with ConPTY #1826

Open
LPGhatguy opened this issue May 2, 2019 · 10 comments · May be fixed by #2828
Open

Progress indicator broken on Alacritty with ConPTY #1826

LPGhatguy opened this issue May 2, 2019 · 10 comments · May be fixed by #2828
Labels
bug O-windows Windows related

Comments

@LPGhatguy
Copy link
Contributor

Problem

When updating a toolchain, Rustup tries to draw over its previous progress indicators, but fails, and instead produces beautiful art:

unknown (6)

Steps

  1. rustup update stable, or another command that causes Rustup to output progress

Possible Solution(s)

Bash in Alacritty in Windows is a pretty weird config. 😄

Notes

Windows 10, Build 1809.

Alacritty has enable_experimental_conpty_backend set, which uses the Windows ConPTY API (1809+ only) instead of WinPTY, which is pretty buggy.

$ alacritty --version
alacritty 0.3.2
$ rustup --version
rustup 1.18.1 :: 1.18.0+20 (462683b3a 2019-04-25) dirty 1 modification
@LPGhatguy LPGhatguy added the bug label May 2, 2019
@rbtcollins
Copy link
Contributor

So this is interesting; it looks like we're either not sending a \r correctly, or the number of spaces being sent to overwrite content is wrong, leading to wrapping to the next line, and so on. Probably some diagnostic testing will be needed to determine what terminfo we're ending up with with term today.

@rbtcollins
Copy link
Contributor

Capturing from discord:
TERM= rustup toolchain add nightly displays correctly but without colour. TERM=xterm-256color otherwise.

The term package fallsback to probing the Windows Console via console APIs when TERM is unset, and if that fails, rustup then creates a Terminal object that tries to work with dumb terminals (e.g. just depends on \r and discards attempts to do bold/colour etc).

So there are two possible code paths we're encountering here when you set TERM=

  • Windows console detected by term.
  • Rustup no-terminfo-fallback.

So this raises several aspects:
-> either we have some weird bug, or alacritty isn't actually xterm-256color compatible.
-> we may have a conpty detection bug
->or we may have a bug doing colour on a detected windows console with conpty

For the latter two need to know which of the code paths we're following; for the former, that seems most likely to be an alacritty issue.
I'm not sure how to tell which we've encountered from a binary; I suggest building a rustup with some debug code (insert into fn make_terminal<T>(terminfo: Option<TermInfo>) -> Option<Box<Terminal<Output = T> + Send>> in term2.rs). - that should let you determine which path is being followed.

If the Windows console path is being detected, I would have expected colour to work; so I suspect that its not being detected, and you are ending up with the no-terminfo-fallback.

@kinnison
Copy link
Contributor

kinnison commented May 7, 2019

This kind of failure mode is something we attempted to fix with the downgrade of term to before the fallback terminfo thing. I wonder what we could do to output some useful debugging of what kind of terminal object we've ended up with?

@davidhewitt
Copy link

I just discovered that this issue is not unique to Alacritty: if TERM is set in Windows Terminal then the output is broken in the same way as with Alacritty.

This might turn out to be an issue in all ConPTY-backed terminal emulators when TERM is set to xterm-256color?

@kinnison
Copy link
Contributor

It's quite probable that this is true yes. ConPTY is not really an ANSI/VTxxx terminal which is part of the reason to want to shift to a more modern windows-aware library.

@davidhewitt
Copy link

I get the impression from discussion on microsoft/terminal that they're working very hard to support VT (and considering the Windows console APIs mostly for legacy programs).

If we can identify a VT sequence we're emitting which Windows is handling incorrectly and report it as a bug upstream, I'm fairly sure they'll fix it.

@kinnison
Copy link
Contributor

So a lot of the issue is that terminal IO crates which expect to be able to deal in VT like commands tend to expect terminfo databases to be available at well known POSIX paths. They tend to assume therefore that if they're on Windows, the only thing they should do is ConPTY. What we need is to move to a terminal crate which does a better job of that, such as indicatif and we have an issue open to think about that, but little to no time has been invested yet in working out what it'd take to do.

@workingjubilee
Copy link
Contributor

@rustbot label: +O-windows

@rustbot rustbot added the O-windows Windows related label Apr 29, 2021
@kirawi
Copy link

kirawi commented Jul 16, 2021

I've got something working, hopefully I'll be able to submit a PR later today.

@kirawi kirawi linked a pull request Jul 16, 2021 that will close this issue
@ryanavella
Copy link

I'm seeing the same thing on FreeBSD whether TERM is xterm or xterm-256color, so maybe this isn't purely a ConPTY thing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug O-windows Windows related
Projects
None yet
8 participants