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 bar prints each update on a new line #4647

Closed
irfinnew opened this issue Oct 6, 2017 · 3 comments
Closed

Progress bar prints each update on a new line #4647

irfinnew opened this issue Oct 6, 2017 · 3 comments

Comments

@irfinnew
Copy link

irfinnew commented Oct 6, 2017

Note that this bug is not fixed by #4317, it has a different cause.

The erratic behaviour, on Yarn 1.1.0, NodeJS v6.11.4, Debian 9.1, rxvt terminal emulator (TERM=rxvt):

yarn_progressbar

Strace shows that Yarn prints the progress bar without any control characters such as \r (in fact, not even \n, so technically all updates are on one huge line...):

22145 write(2, "[--------------------------------------------------------------------------------------------------------------------------] 0/1138", 131) = 131
22145 write(2, "[--------------------------------------------------------------------------------------------------------------------------] 3/1138", 131) = 131
22145 write(2, "[#-------------------------------------------------------------------------------------------------------------------------] 5/1138", 131) = 131
22145 write(2, "[#-------------------------------------------------------------------------------------------------------------------------] 7/1138", 131 <unfinished ...>

After some prodding and poking, I found out that Yarn does print the progress bar properly when the COLORTERM environment variable is set:

yarn_progressbar2

Strace reveals that in this case, Yarn is emitting control characters, in a separate write (why not simply \r instead of ^[[1G? Ehh...):

22401 write(2, "[--------------------------------------------------------------------------------------------------------------------------] 0/1138", 131) = 131
22401 write(2, "\33[1G", 4)             = 4
22401 write(2, "[--------------------------------------------------------------------------------------------------------------------------] 3/1138", 131) = 131
22401 write(2, "\33[1G", 4 <unfinished ...>
22401 write(2, "[#-------------------------------------------------------------------------------------------------------------------------] 5/1138", 131) = 131
22401 write(2, "\33[1G", 4)             = 4
22401 write(2, "[#-------------------------------------------------------------------------------------------------------------------------] 7/1138", 131) = 131
22401 write(2, "\33[1G", 4)             = 4

But this environment variable is both optional and obsolete, so Yarn should not rely on it.

@BYK
Copy link
Member

BYK commented Oct 7, 2017

Ah, great find! Would you like to submit a PR and get your name in the commit history for both discovering and fixing this annoyance? :)

arcanis pushed a commit that referenced this issue Oct 12, 2017
If the output does not support color, then each render of the progress
bar is added to a single line, which wraps over multiple lines.

As a fallback, a simple carriage return is used to move to the start of
the line, and space characters to clear the line.
@irfinnew
Copy link
Author

Hehe, nwholloway beat me to it :)

His fix works for me!

@arcanis
Copy link
Member

arcanis commented Oct 12, 2017

Thanks anyway for letting us know :)

@arcanis arcanis closed this as completed Oct 12, 2017
skevy pushed a commit to expo/yarn that referenced this issue Oct 16, 2017
skevy pushed a commit to expo/yarn that referenced this issue Oct 25, 2017
joaolucasl pushed a commit to joaolucasl/yarn that referenced this issue Oct 27, 2017
If the output does not support color, then each render of the progress
bar is added to a single line, which wraps over multiple lines.

As a fallback, a simple carriage return is used to move to the start of
the line, and space characters to clear the line.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants