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: UNCONFIRMED
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: PullRequest
Depends on:
Blocks:
 
Reported: 2024-11-29 22:33 UTC by Thibaud CANALE
Modified: 2024-12-08 00:00 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.