How to set the locales in a toolbox?

Hi, I would like to be able to set the locale to en_US.UTF-8 in a toolbox running Fedora rawhide.
The toolbox is running in a Kinoite system.
The usual way for mutable OS does not work because localectl does not work:

[X@toolbox ~]$ localectl
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

Slackoverflow provides solutions for Docker but not for podman as far as I could find anything.

Perhaps the solution is to use localedef but I don’t know what I am doing…

Thanks for your help!

1 Like

The most straightforward way is probably that you set the locale environment variables, for example

export LC_ALL=en_US.UTF-8

or to make it permanent in the current toolbox container:

echo export LC_ALL=en_US.UTF-8 >> /etc/profile.d/toolbox-locale.sh

(LC_ALL will override all other locale settings, for the full list of more fine grained settings, see man 5 locale)

1 Like

Many thanks, there is progress but it does not yet fully work.

I guess the export should be done in the host OS (in the toolbox it does not work).
That works, but then, then the following command did not work:

[X@fedora ~]$ sudo echo export LC_ALL=en_US.UTF-8 >> /etc/profile.d/toolbox-locale.sh
bash: /etc/profile.d/toolbox-locale.sh: Permission denied

So I tried to directly create the file manually:

sudo nano /etc/profile.d/toolbox-locale.sh

and pasted in there export LC_ALL=en_US.UTF-8.

That did work.

Then I restarted the toolbox:

podman restart NAMEOFTOOLBOX

So now we have:

[X@toolbox ~]$ locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

which seems to contain issues and indeed makes the software I use still unhappy.

Any ideas?

If you just want to modify the locale inside the toolbox, I’d expect that both that export command and editing the profile file would be done inside the toolbox.

I don’t think it is possible like that:

[X@toolbox ~]$ export LC_ALL=en_US.UTF-8
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

That’s most likely because that locale is not installed. You should be able to install it with

sudo dnf -y install glibc-langpack-en

(again inside the toolbox container)

3 Likes

Indeed, many thanks!!!