Open acid-bong opened 1 week ago
cc @NixOS/systemd
It's not clear to me from that systemd issue thread what NixOS specifically is doing wrong here. Can anyone explain?
@ElvishJerricco systemd as root doesn't handle locale properly:
❯ locale
LANG=ru_RU.UTF-8
LC_CTYPE="ru_RU.UTF-8"
LC_NUMERIC="ru_RU.UTF-8"
LC_TIME="ru_RU.UTF-8"
LC_COLLATE="ru_RU.UTF-8"
LC_MONETARY="ru_RU.UTF-8"
LC_MESSAGES="ru_RU.UTF-8"
LC_PAPER="ru_RU.UTF-8"
LC_NAME="ru_RU.UTF-8"
LC_ADDRESS="ru_RU.UTF-8"
LC_TELEPHONE="ru_RU.UTF-8"
LC_MEASUREMENT="ru_RU.UTF-8"
LC_IDENTIFICATION="ru_RU.UTF-8"
LC_ALL=
❯ run0 !!
run0 locale
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ====
Authentication is required to manage system services or other units.
Authenticating as: acid
Password:
==== AUTHENTICATION COMPLETE ====
/run/current-system/sw/bin/locale: Cannot set LC_CTYPE to default locale: No such file or directory
/run/current-system/sw/bin/locale: Cannot set LC_MESSAGES to default locale: No such file or directory
/run/current-system/sw/bin/locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=ru_RU.UTF-8
LC_CTYPE="ru_RU.UTF-8"
LC_NUMERIC="ru_RU.UTF-8"
LC_TIME="ru_RU.UTF-8"
LC_COLLATE="ru_RU.UTF-8"
LC_MONETARY="ru_RU.UTF-8"
LC_MESSAGES="ru_RU.UTF-8"
LC_PAPER="ru_RU.UTF-8"
LC_NAME="ru_RU.UTF-8"
LC_ADDRESS="ru_RU.UTF-8"
LC_TELEPHONE="ru_RU.UTF-8"
LC_MEASUREMENT="ru_RU.UTF-8"
LC_IDENTIFICATION="ru_RU.UTF-8"
LC_ALL=
I'm not sure it matters, but at least LOCALE_ARCHIVE_2_27
is not set in there (LOCALE_ARCHIVE
seems to be though).
Aha, a solution turns out to be to include LOCALE_ARCHIVE
in the run0
env:
❯ run0 --setenv=LOCALE_ARCHIVE printenv
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ====
Authentication is required to manage system services or other units.
Authenticating as: acid
Password:
==== AUTHENTICATION COMPLETE ====
LANG=ru_RU.UTF-8
PATH=/nix/store/1lbc6v5p1a3rn4rjaqnz0694xfbq8dxq-systemd-256.4/bin/
USER=root
LOGNAME=root
HOME=/root
SHELL=/bin/sh
INVOCATION_ID=2539aed89f5742aa875730ea78bd70e6
TERM=st-256color
SYSTEMD_EXEC_PID=840737
MEMORY_PRESSURE_WATCH=/sys/fs/cgroup/user.slice/run-u365.service/memory.pressure
MEMORY_PRESSURE_WRITE=c29tZSAyMDAwMDAgMjAwMDAwMAA=
LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive
SUDO_USER=acid
SUDO_UID=1000
SUDO_GID=100
❯ run0 --setenv=LOCALE_ARCHIVE ls
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ====
Authentication is required to manage system services or other units.
Authenticating as: acid
Password:
==== AUTHENTICATION COMPLETE ====
ardour iso olbackup org src www Видео Загрузки Музыка 'Рабочий стол'
Documents kernel-report olbackup2 prog Sync бекуп Документы Изображения Общедоступные Шаблоны
And, of course, locale
command not doesn't misbehave like there
❯ run0 --setenv=LOCALE_ARCHIVE locale
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ====
Authentication is required to manage system services or other units.
Authenticating as: acid
Password:
==== AUTHENTICATION COMPLETE ====
LANG=ru_RU.UTF-8
LC_CTYPE="ru_RU.UTF-8"
LC_NUMERIC="ru_RU.UTF-8"
LC_TIME="ru_RU.UTF-8"
LC_COLLATE="ru_RU.UTF-8"
LC_MONETARY="ru_RU.UTF-8"
LC_MESSAGES="ru_RU.UTF-8"
LC_PAPER="ru_RU.UTF-8"
LC_NAME="ru_RU.UTF-8"
LC_ADDRESS="ru_RU.UTF-8"
LC_TELEPHONE="ru_RU.UTF-8"
LC_MEASUREMENT="ru_RU.UTF-8"
LC_IDENTIFICATION="ru_RU.UTF-8"
LC_ALL=
Judging by the PATH value, this printenv
output is the only env that PID1 is aware about. Would it be a good idea to add LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive
to that env?
I didn't find the place yet where systemd keeps that list around, but I assume propagating that env variable too might be something upstreamable.
I noticed that run0
doesn't load envvars from PAM, just like doas. I'll address that in the original issue
Describe the bug
Only the interactive
run0
session displays non-ASCII symbols properly, the non-interactive doesn't. Also it falls back to English/C locale, despiterun0 printenv
showing the same locale as usual.Steps To Reproduce
Steps to reproduce the behavior:
ls
in a directory with file names in, say, Cyrillic and a program that is Russified (likedf -h
)run0
to each commandrun0
sessionExpected behavior
run0
shouldn't change locale settings, just like sudo.Pastes
Additional context
First reported in https://github.com/systemd/systemd/issues/34682, turned out to be locale-/distro-specific (one of maintainers uses Fedora and doesn't have that issue). More pastes (long ones) there.
Notify maintainers
@flokli i guess
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result.Add a :+1: reaction to issues you find important.