Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Error] Failed to set locale error on Fedora image #258

Closed
aral opened this issue May 4, 2022 · 12 comments
Closed

[Error] Failed to set locale error on Fedora image #258

aral opened this issue May 4, 2022 · 12 comments
Labels
bug Something isn't working

Comments

@aral
Copy link

aral commented May 4, 2022

Summary

When you install a Fedora image (:latest) with Distrobox, running commands that require a locale to be set (e.g., dnf) show a warning.

To Reproduce

  1. Install the fedora image
  2. enter dnf --version

What should happen

You should see the version string.

What actually happens

  ~                                                                           
❯ dnf --version
Failed to set locale, defaulting to C.UTF-8
4.9.0
  Installed: dnf-0:4.9.0-1.fc35.noarch at Mon Feb 21 06:47:57 2022
  Built    : Fedora Project at Thu Sep 23 12:18:24 2021

  Installed: rpm-0:4.17.0-4.fc35.x86_64 at Mon Feb 21 06:47:56 2022
  Built    : Fedora Project at Wed Feb  2 12:39:01 2022

It appears that localectl is also not present in the container.

Proposed solution

Set the locale of the image when configuring it (to match the locale of the host).

Desktop (please complete the following information):

  • OS: [e.g. iOS] Fedora Silverblue
  • Version [e.g. 22] 36

Additional context

Note that the locale on the host system is set properly.

🔒   ~                                                                                                                         5m 41s
❯ localectl
   System Locale: LANG=en_IE.UTF-8
       VC Keymap: us-mac
      X11 Layout: us
     X11 Variant: mac
@aral aral added the bug Something isn't working label May 4, 2022
@aral
Copy link
Author

aral commented May 4, 2022

Oh, wow, the fedora image seems to be missing systemd altogether. That might cause it, I guess :)

@aral
Copy link
Author

aral commented May 4, 2022

This seems to be an issue with the fedora-toolbox image also which I believe is what toolbox uses too (but toolbox’s version of Fedora includes systemd so I’m assuming it’s setup when the image is initialised.)

So the same issue is present in the fedora-toolbox image but that, at least, includes systemd.

Spoke too soon: Oddly, I also cannot run any systemd commands in the fedora-toolbox image.

I get (e.g.):

❯ systemctl 
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

I have no such problems with container based on the Ubuntu image.

Is there room here for Distrobox to do better than toolbox and fix this during container initialisation?

@aral
Copy link
Author

aral commented May 4, 2022

@aral
Copy link
Author

aral commented May 4, 2022

From inside the container:

❯ 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_IE.UTF-8
LC_CTYPE="en_IE.UTF-8"
…
LC_MESSAGES="en_IE.UTF-8"
…
LC_ALL=

Related: containers/toolbox#60

@aral
Copy link
Author

aral commented May 4, 2022

Solution:

From within the Fedora container:

sudo dnf install glibc-langpack-en

This installs the full English language pack (instead of the minimal) – about a 3MB download (so not huge).

You can also install glibc-all-langpacks if your locale is not en (or your specific one given that the all language pack is reportedly several hundred megabytes).

Please feel free to close this issue unless you feel Distrobox can do something here during container initialisation to improve this experience.

@89luca89
Copy link
Owner

89luca89 commented May 4, 2022

Hi @aral thanks for the report!

Problem here is that... well I can't reproduce it 😞

Here are 2 examples with fedora-toolbox image and with a normal fedora image:

image
image

In both cases, locale is:

locale
LANG=C.UTF-8
LC_CTYPE=C.UTF-8
LC_NUMERIC="C.UTF-8"
LC_TIME="C.UTF-8"
LC_COLLATE="C.UTF-8"
LC_MONETARY="C.UTF-8"
LC_MESSAGES="C.UTF-8"
LC_PAPER="C.UTF-8"
LC_NAME="C.UTF-8"
LC_ADDRESS="C.UTF-8"
LC_TELEPHONE="C.UTF-8"
LC_MEASUREMENT="C.UTF-8"
LC_IDENTIFICATION="C.UTF-8"
LC_ALL=

@aral
Copy link
Author

aral commented May 4, 2022

@89luca89 I believe this happens when the locale of your base system is anything but the base language. I’m assuming the base OS (running in a VM) has its locale set to C.UTF-8?

@89luca89
Copy link
Owner

89luca89 commented May 4, 2022

No my base OS has:

luca-linux@localhost:~> locale
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=

@89luca89
Copy link
Owner

89luca89 commented May 4, 2022

Thinking of it, are you exporting LC_* stuff inside dotfiles or something like that? that may be the reason 🤔

@aral
Copy link
Author

aral commented May 4, 2022

@89luca89 Hah, interesting… and no, not that I know of.

You know what, I wouldn’t worry too much about it. Feel free to close this issue for now. It’s documented really well here. If someone else runs into it they (a) have a workaround (b) might be able to get us to narrow it down further. It’s probably not worth wasting your time over at the moment :)

@89luca89
Copy link
Owner

89luca89 commented May 5, 2022

Cool, thanks for the discussion!

@89luca89 89luca89 closed this as completed May 5, 2022
@J3RN
Copy link

J3RN commented Jul 18, 2023

I just wanted to comment that I had this issue also, today, on the default Fedora 38 image. Just installing glibc-langpack-en didn't fix it. Fortunately I stumbled into /etc/locale.conf, found that it contained LANG="C.UTF-8", changed that to LANG="en_US.UTF-8", exited the box, re-entered the box, and all is well!

[j3rn@my-distrobox ~ 16:33]$ locale
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=

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants