You are not logged in.

#1 2025-01-05 14:07:02

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 531

[SOLVED] pacman shows blank package versions under tmux in virtual con

This is not a big problem, I note it here because it may confuse users like it puzzled me this time.

Under tmux in virtual console pacman -S ... displays a list of packages to be installed with blank versions:
8ijb.png
(no need to install packages, just let it display a list).

Without tmux versions are displayed in the same color as names:
8ijT.png
The same if tmux is forced to assume that terminal supports 256 colors with -T 256.

Under screen versions are displayed as usual, in gray color, like in terminal emulators.

It looks like a coincidence of two circumstances:

1. pacman uses ECMA-48 "256 color" variant of command 38 for faint color regardless of terminal it is running on: /src/pacman/conf.c:66.
However, even if it checked termcap database, it wouldn't work because tmux always sets TERM=tmux-256color.

2. tmux clamps "unknown" colors to 0x00 for some reason. Here is part of hexdump of /dev/vsca1 under tmux:

00000960  20 07 20 07 50 0f 61 0f  63 0f 6b 0f 61 0f 67 0f  | . .P.a.c.k.a.g.|
00000970  65 0f 73 0f 20 0f 28 0f  31 0f 29 0f 20 07 66 07  |e.s. .(.1.). .f.|
00000980  69 07 6c 07 65 07 73 07  79 07 73 07 74 07 65 07  |i.l.e.s.y.s.t.e.|
00000990  6d 07 2d 00 32 00 30 00  32 00 34 00 2e 00 31 00  |m.-.2.0.2.4...1.|
000009a0  31 00 2e 00 32 00 31 00  2d 00 31 00 20 07 20 07  |1...2.1.-.1. . .|

Character attribues in version are `00`.

Compare to attributes without tmux:

00000960  20 07 20 07 50 0f 61 0f  63 0f 6b 0f 61 0f 67 0f  | . .P.a.c.k.a.g.|
00000970  65 0f 73 0f 20 0f 28 0f  31 0f 29 0f 20 07 66 07  |e.s. .(.1.). .f.|
00000980  69 07 6c 07 65 07 73 07  79 07 73 07 74 07 65 07  |i.l.e.s.y.s.t.e.|
00000990  6d 07 2d 07 32 07 30 07  32 07 34 07 2e 07 31 07  |m.-.2.0.2.4...1.|
000009a0  31 07 2e 07 32 07 31 07  2d 07 31 07 20 07 20 07  |1...2.1.-.1. . .|
000009b0  20 07 20 07 20 07 20 07  20 07 20 07 20 07 20 07  | . . . . . . . .|

and under screen:

00000960  20 07 20 07 50 0f 61 0f  63 0f 6b 0f 61 0f 67 0f  | . .P.a.c.k.a.g.|
00000970  65 0f 73 0f 20 0f 28 0f  31 0f 29 0f 20 07 66 07  |e.s. .(.1.). .f.|
00000980  69 07 6c 07 65 07 73 07  79 07 73 07 74 07 65 07  |i.l.e.s.y.s.t.e.|
00000990  6d 07 2d 08 32 08 30 08  32 08 34 08 2e 08 31 08  |m.-.2.0.2.4...1.|
000009a0  31 08 2e 08 32 08 31 08  2d 08 31 08 20 07 20 07  |1...2.1.-.1. . .|
000009b0  20 07 20 07 20 07 20 07  20 07 20 07 20 07 20 07  | . . . . . . . .|

So it looks like tmux is the main culprit.

There may be many possible workarounds: turn pacman colors off, force tmux to assume 256-color terminal if TERM==linux, etc.
I'd like to know what is ideologically correct way to fix such kind of issues and how to avoid them.

Last edited by dimich (2025-04-30 17:20:26)

Offline

#2 2025-01-05 17:23:50

dakota
Member
Registered: 2016-05-20
Posts: 415

Re: [SOLVED] pacman shows blank package versions under tmux in virtual con

I can not duplicate this problem.

Running "sudo pacman -S filesystem" inside tmux yields the same results as in your second screenshot except the word "filesystem" is the same off-white color as "Packages" (the "-2024.11.21-1" is grey, as shown).

TERM=tmux-256color

Cheers,


"Before Enlightenment chop wood, carry water. After Enlightenment chop wood, carry water." -- Zen proverb

Offline

#3 2025-01-05 17:59:37

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 531

Re: [SOLVED] pacman shows blank package versions under tmux in virtual con

dakota wrote:

Running "sudo pacman -S filesystem" inside tmux yields the same results as in your second screenshot

Hm. I see this issue on three different machines running Arch.
Did you run tmux in virtual console? I.e. if you're in GUI session, Ctrl+Alt+F1 and login there?

Offline

#4 2025-01-05 21:09:41

dakota
Member
Registered: 2016-05-20
Posts: 415

Re: [SOLVED] pacman shows blank package versions under tmux in virtual con

Did you run tmux in virtual console?

Oops. Missed that.

I was running the command in a terminal emulator (xterm). When I run the command in the console, I see exactly what you see.

I remember spending a lot of time trying to get a vim, tmux, and console colors to work together, but it was all too much effort and I switched to always using a terminal emulator inside a GUI. (About the same time, I had to switch nvidia drivers, which made the console nearly unusable -- so it was a moot point.)

Cheers,


"Before Enlightenment chop wood, carry water. After Enlightenment chop wood, carry water." -- Zen proverb

Offline

#5 2025-01-05 22:42:22

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 531

Re: [SOLVED] pacman shows blank package versions under tmux in virtual con

dakota wrote:

I switched to always using a terminal emulator inside a GUI.

Usually I also work in terminal emulator but sometimes use old netbook w/o GUI (and occasionally access it via ssh, therefore use tmux). At times experiment with Xorg/DMs so have to use virtual console.
Developers sometimes forget that console applications should work in console too. Sometimes they even assume that user has to install a bunch of emoji fonts to use their console applications.

dakota wrote:

(About the same time, I had to switch nvidia drivers, which made the console nearly unusable -- so it was a moot point.)

Yeah right, I struggled with it too. Finally they made KMS and efifb friends, so now it is usable.

Offline

#6 2025-01-06 12:34:04

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 73,774

Re: [SOLVED] pacman shows blank package versions under tmux in virtual con

From https://github.com/tmux/tmux/issues/3009 it seems to check the $TERM, does it matter how/where you start the (specific) tmux server, ie. does "tmux" from the console act different from "tmux attach" to some running instance that was started elsewhere™

screen seems to default to the tmux -2 behavior?

Offline

#7 2025-01-06 13:36:09

dakota
Member
Registered: 2016-05-20
Posts: 415

Re: [SOLVED] pacman shows blank package versions under tmux in virtual con

seth wrote:

does "tmux" from the console act different from "tmux attach" to some running instance that was started elsewhere™

Yes.

If I open a graphical environment (fluxbox), then start tmux, I see the colors I described in post #2.

If I then: $ tmux detach ==> ctrl+alt+F2 ==> login to the console ==> $ tmux attach...
... I see the same  colors as dimich's 1st posted photo.

In both cases (from within tmux)

$ echo $TERM
~~~~~~~~~~~~~~~
tmux-256color

From within fluxbox, without tmux running

$ echo $TERM
~~~~~~~~~~~~~~~
xterm-256color

From within the console, without tmux running

$ echo $TERM
~~~~~~~~~~~~~~~
linux

Cheers,

Last edited by dakota (2025-01-06 13:36:33)


"Before Enlightenment chop wood, carry water. After Enlightenment chop wood, carry water." -- Zen proverb

Offline

#8 2025-01-06 18:21:50

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 531

Re: [SOLVED] pacman shows blank package versions under tmux in virtual con

seth wrote:

From https://github.com/tmux/tmux/issues/3009 it seems to check the $TERM

TERM in virtual console is "linux", as set by kernel for init process. Changing TERM to "xterm-256color" for tmux has the same effect as "-2": it makes tmux assume that underlying terminal understand 256 colors.

When tmux assusmes that underlying terminal understand 256 colors, either from TERM or forced by "-2", it passes 256-color sequence as is.

In 256-color capable terminal GREY46 color ("\033[38;5;243m" printed by pacman) makes version string grayish.
In "linux" terminal GREY46 color is "shoehorned into 16 basic colors", as noted in console_codes(4) and version string is displayed in the same color as package name.

When tmux assumes that underlying terminal doesn't understand 256 colors, it replaces 256-color command with "set black foreground" command. I didn't have a chance to explore tmux sources yet to find where exactly does it do this.

seth wrote:

does it matter how/where you start the (specific) tmux server, ie. does "tmux" from the console act different from "tmux attach" to some running instance that was started elsewhere™

tmux started in xterm, attached in virtual console: version is blank.
tmux started in virtual console, attached in xterm: version is visible (dark gray).

seth wrote:

screen seems to default to the tmux -2 behavior?

Not exactly. Under screen version is displayed dark gray, it looks like in X terminal emulators:
8iv0.png

Here are typescripts captured by script command:

"Raw" linux console:

.[0;1mPackages (1).[0m filesystem.[38;5;243m-2024.11.21-1.[0m

Console driver then "schoehornes" color 243 into gray (color 7 in 16-colors palette).

`screen`:

.[1mPackages (1).[m. filesystem.[38;5;8m-2024.11.21-1.[39m.[6;1H

screen replaces "[38;5;243m" with "[38;5;8m", i.e. maps color 243 to color 8 (dark gray in 16-colors palette).

`tmux`:

.[1mPackages (1).[m. filesystem.[30m-2024.11.21-1.[8;1H

tmux replaces "[38;5;243m" with "[30m", i.e. "set black foreground".

`tmux -2` (the same with `TERM=xterm-256color tmux`):

.[1mPackages (1).[m. filesystem.[38;5;243m-2024.11.21-1.[8;1H

"[38;5;243m" unchanged, it works like in raw console.

Offline

#9 2025-01-07 12:22:42

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 531

Re: [SOLVED] pacman shows blank package versions under tmux in virtual con

Heh, for non-256color terminals tmux maps color 243 to color 8 first: colour.c:352
But according to ncurses terminfo database, terminal "linux" supports only 8 colors:

$ tput colors -T linux
8

Thus tmux clears 8th bit and ligitimately omits using code for bright version of foreground: tty.c:2880
Foreground color becomes 0 (black).

I'd suggest tmux to use color 7 as fallback in this case.

So yet another workaround may be to set Environment=TERM=linux-16color for getty@.service (I didn't test this yet).
Perhaps, the kernel could set TERM=linux-16color for init if console is in framebuffer. However, it is unclear how to handle further runtime changes.

The problem also would not arise if pacman used color 244 instead of 243 for faint color. Although, under screen in virtual console color 244 makes version to be dispayed gray, not dark gray hmm
Is it worth a pull request?

Offline

#10 2025-01-07 12:53:36

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,651
Website

Re: [SOLVED] pacman shows blank package versions under tmux in virtual con

The request would likely be ignored forever as the lowest of low priority....   Just disable color.

Offline

#11 2025-01-07 14:54:42

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 531

Re: [SOLVED] pacman shows blank package versions under tmux in virtual con

Created PR for tmux. Let's see.

Offline

#12 2025-04-30 17:18:53

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 531

Re: [SOLVED] pacman shows blank package versions under tmux in virtual con

After discussion with upstream I end up with the issue by this workaround in tmux.conf:

set -sa terminal-overrides "linux:colors=256"

Offline

Board footer

Powered by FluxBB