Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 945382 - sys-apps/portage-3.0.66(-r1): status line too wide, no automatic adjust
Summary: sys-apps/portage-3.0.66(-r1): status line too wide, no automatic adjust
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Interface (emerge) (show other bugs)
Hardware: All Linux
: Normal trivial
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on: 939444
Blocks:
  Show dependency tree
 
Reported: 2024-11-29 22:33 UTC by Thibaud CANALE
Modified: 2025-01-22 00:30 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thibaud CANALE 2024-11-29 22:33:19 UTC
When using emerge in tmux since the introduction of "merge wait" status component since Portage release 3.0.66 with a terminal width of 80 columns, the terminal is flooded with incomplete status lines.
This happens because the status line is by default too wide to enter in a 80 columns, however this does not happen every time.

I noticed in the source code, file `lib/_emerge/JobStatusDisplay.py`, it should “Truncate to fit width, to avoid making the terminal scroll if the line overflows”.

I made some test, with and without tmux, with direct invocation of Python (I replaced `self.out` by `sys.stdout`, see @property out of class `JobStatusDisplay`)

```
# Without tmux
% python3 -c 'import os, sys; print(os.environ.get("TERM") != "dumb" and hasattr(sys.stdout, "isatty") and sys.stdout.isatty(), file=sys.stderr)'
True

% python3 -c 'import curses, os, sys; curses.setupterm(term=os.environ.get("TERM", "unknown"), fd=sys.stdout.fileno()); print(curses.tigetnum("lines"), curses.tigetnum("cols"), file=sys.stderr);'
24 80


# With tmux
% python3 -c 'import os, sys; print(os.environ.get("TERM") != "dumb" and hasattr(sys.stdout, "isatty") and sys.stdout.isatty(), file=sys.stderr)'
True

% python3 -c 'import curses, os, sys; curses.setupterm(term=os.environ.get("TERM", "unknown"), fd=sys.stdout.fileno()); print(curses.tigetnum("lines"), curses.tigetnum("cols"), file=sys.stderr);'
23 80
# 23 instead of 24 because of Tmux’s own status line.
```

In commit a28a0fd6600242a2e062a0fd2d7d5be95296b7ae (and tweaks in 9f919c387fbc4c8526535b03fb781ab2a01ddfdd and 225e574108549ac85dd743bfbc0c3d5e2e740c60), the default value was raised to 100 from 80, while also reporting in its message the function “self._isatty has the tendency to return false, even though portage is actually run within a tty”.

Reproducible: Sometimes

Steps to Reproduce:
1. run emerge, such as `emerge -vatuD @world`
2. see line status too wide, flooding terminal.
Comment 1 Thibaud CANALE 2024-12-04 21:21:28 UTC
I think this ticket can be closed, I didn’t understand the width of the terminal is queried at start, not during.
And by usage, I used to resize the terminal width before and/or during so I can better read its output. Hence why I see sporadicly this issue.

Unless emerge supports resize during execution, this is the correct behaviour, no actual bug is present.

I let you decide if you prefer to close as-is the ticket or to implement dynamic width.

Until then, sorry for the noise.
Comment 2 Zac Medico gentoo-dev 2024-12-04 23:05:07 UTC
We certainly could handle SIGWINCH in order to adjust to terminal size changes dynamically.
Comment 3 Thibaud CANALE 2024-12-07 16:38:46 UTC
Renaming mainly to remove tmux mention.
Comment 4 Zac Medico gentoo-dev 2024-12-08 00:00:57 UTC
In https://github.com/gentoo/portage/pull/1402 I had to disable curses usage since it returned a stale width after terminal resize.
Comment 5 Larry the Git Cow gentoo-dev 2024-12-28 02:05:46 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=3e3bb8e67abc421824ccbf978aea6a0040e0ca92

commit 3e3bb8e67abc421824ccbf978aea6a0040e0ca92
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2024-12-10 21:13:12 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2024-12-28 02:04:57 +0000

    Scheduler: Handle SIGWINCH for JobStatusDisplay
    
    Do not use curses in the get_term_size function, since curses caches
    the terminal width and does not account for resize.
    
    Bug: https://bugs.gentoo.org/945382
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 NEWS                            |  2 ++
 lib/_emerge/JobStatusDisplay.py | 14 +++++++++-----
 lib/_emerge/Scheduler.py        | 11 +++++++++++
 lib/portage/output.py           | 15 +++++----------
 4 files changed, 27 insertions(+), 15 deletions(-)
Comment 6 Larry the Git Cow gentoo-dev 2025-01-22 00:30:31 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=03f41049a0fe0632eabd8cddaaca898e45943201

commit 03f41049a0fe0632eabd8cddaaca898e45943201
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2025-01-22 00:29:50 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2025-01-22 00:30:02 +0000

    sys-apps/portage: add 3.0.67
    
    Closes: https://bugs.gentoo.org/703520
    Closes: https://bugs.gentoo.org/707980
    Closes: https://bugs.gentoo.org/904702
    Closes: https://bugs.gentoo.org/906044
    Closes: https://bugs.gentoo.org/923530
    Closes: https://bugs.gentoo.org/938164
    Closes: https://bugs.gentoo.org/939299
    Closes: https://bugs.gentoo.org/940120
    Closes: https://bugs.gentoo.org/942512
    Closes: https://bugs.gentoo.org/942760
    Closes: https://bugs.gentoo.org/945382
    Closes: https://bugs.gentoo.org/945861
    Closes: https://bugs.gentoo.org/946326
    Closes: https://bugs.gentoo.org/947822
    Closes: https://bugs.gentoo.org/948067
    Closes: https://bugs.gentoo.org/939444
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-apps/portage/Manifest              |   1 +
 sys-apps/portage/portage-3.0.67.ebuild | 231 +++++++++++++++++++++++++++++++++
 2 files changed, 232 insertions(+)