rust-lang / rust-lang/cargo

Cargo doesn't clear line when progress bars force-enabled

Open
#9,155 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-console-output C-bug S-needs-design
Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
23h 30m
Merged PRs (30d)
51

Description

When building with CARGO_TERM_PROGRESS_WIDTH=100 CARGO_TERM_PROGRESS_WHEN=always cargo build, with stdout/stderr directed somewhere other than a tty, cargo doesn't seem to clear to the end of the line when overwriting a line containing a progress bar.

Correct behavior, with stdout/stderr going to a terminal:

~/src/cargo$ CARGO_TERM_PROGRESS_WIDTH=100 CARGO_TERM_PROGRESS_WHEN=always cargo build
   Compiling libc v0.2.86
   Compiling pkg-config v0.3.16
   Compiling cfg-if v0.1.10
   Compiling autocfg v0.1.6
   Compiling lazy_static v1.4.0
   Compiling proc-macro2 v1.0.5
    Building [                                                         ] 2/153: libc(build.rs),...

Incorrect behavior, with stdout/stderr going to a pipe:

~/src/cargo$ CARGO_TERM_PROGRESS_WIDTH=100 CARGO_TERM_PROGRESS_WHEN=always cargo build 2>&1 | cat
   Compiling libc v0.2.86
   Compiling pkg-config v0.3.16
   Compiling cfg-if v0.1.10
   Compiling autocfg v0.1.6
   Compiling lazy_static v1.4.0                                        ] 0/153: pkg-config, cfg...
   Compiling proc-macro2 v1.0.5                                        ] 1/153: pkg-config, aut...
   Compiling unicode-xid v0.2.0                                        ] 2/153: proc-macro2(bui...
   Compiling syn v1.0.5                                                ] 3/153: proc-macro2(bui...
   Compiling serde v1.0.101                                            ] 4/153: proc-macro2(bui...
   Compiling memchr v2.2.1                                             ] 5/153: proc-macro2(bui...
    Building [=>                                                       ] 6/153: pkg-config, ser...

(Letting it run longer shows that the ===> part of the progress bar doesn't get cleared either.)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with CARGO_TERM_PROGRESS_WIDTH=100 and CARGO_TERM_PROGRESS_WHEN=always while piping cargo build output through cat. Trace the progress-bar output handling for non-TTY streams; done means overwritten lines clear all trailing characters, including progress-bar remnants, when output is redirected.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.