#856663 apt progress bar doesn't play well with dumb terminals

Package:
apt
Source:
apt
Description:
commandline package manager
Submitter:
Mathieu Lirzin
Date:
2025-02-02 17:03:01 UTC
Severity:
normal
#856663#5
Date:
2017-03-03 16:33:28 UTC
From:
To:
Dear Maintainer,

   * What led up to the situation?
   The problem is present 'apt upgrade'.

   * What exactly did you do (or not do) that was effective (or
     ineffective)?
   When using a dumb terminal (i.e. TERM=dumb) the output of the
   progress bar when doing 'apt-upgrade' leave a lot of undesired
   character in the output.

   In my case the terminal used is shell-mode in emacs.  which can
   launch with M-x shell inside emacs.

   * What outcome did you expect instead?
   A clean output.

#856663#10
Date:
2025-02-02 16:53:33 UTC
From:
To:
Hi,

I have tested the behaviour on Debian 12 with unmodified apt 2.6.1 and
emacs 28.2.

The problem still exists.

The problem most probably is NOT related to dumb $TERM used inside of
emacs' shell because:

1. with non-dumb $TERM in emacs' shell the problem still occurs

    I used the following steps to configure non-dumb $TERM after running
    shell in emacs (M-x shell):

    export TERM={linux|xterm-256color}
    tput init
    echo $TERM

    After the three commands I ran apt to observe the progress bar:

    apt {install|remove} libxml2-dev

2. with dumb $TERM in regular shell session (outside of emacs) I
    experienced no problems with progress bar while running "apt
    {install|remove} <package>".


What's interesting is the fact that emacs itself doesn't play well with
dumb $TERM. This is what is being printed in plain shell session when I
attempt to start emacs:

    root@debian:~# emacs
    emacs: Terminal type "dumb" is not powerful enough to run Emacs.
    It lacks the ability to position the cursor.
    [...]


Another interesting thing is the difference between output of "stty -a"
for plain shell and for emacs shell when $TERM is set to dumb, but I
won't bore you with details.

It looks like the problem with progress bars of different programs ran
inside of emacs is known to many people:

npm:
https://stackoverflow.com/questions/21785955/messed-up-progress-bars-when-installing-npm-packages-inside-ansi-term

yarn:
https://github.com/yarnpkg/yarn/issues/4927

pacman:
https://bbs.archlinux.org/viewtopic.php?id=121432
https://gitlab.archlinux.org/pacman/pacman/-/commit/330951200c8a0bb90937e0578510a41220154726

apt:
https://askubuntu.com/questions/956712/prevent-extraneous-formatting-of-apt-output
https://oremacs.com/2019/03/24/shell-apt/


So as a happy user of emacs myself I have to ask if this is a problem
with apt or a problem with emacs.

The last two links propose the following two workarounds:

1. Configure apt to use no fancy progress bar, either in config file or
    like this:

    apt -o Dpkg::Progress-Fancy=0 action args...

2. Use "apt-get" instead of "apt". IIUC, apt-get internally sets
    Progress-Fancy to false internally.

I'm attaching a "kamil_progress_bar.txt" file that shows how the problem
with progress bar looks like in my case. Notice the messages from
debconf.

Kamil