How to fix 'character map file `UTF-8' not found'
Asked Answered
P

3

27

I'm setting up a UBI rhel8 container. I need to execute this command:

localedef -f UTF-8 -i en_US en_US.UTF-8

which failed with:

character map file `UTF-8' not found: No such file or directory
cannot read character map directory `/usr/share/i18n/charmaps': No such file or directory
Protero answered 9/10, 2019 at 12:36 Comment(0)
N
36

You need to install these packages

yum -y install glibc-locale-source glibc-langpack-en

and then re-run localedef command

Newsome answered 2/12, 2019 at 11:5 Comment(3)
Had to reboot like two times.Chrystel
Be aware, that gzip was removed from UBI Images that might fail localedef (see access.redhat.com/solutions/6540691 for details)Variolous
I also needed to install gzip in order to run localedefBhatt
J
11

On Debian/Ubuntu, I was able to solve this via apt install locales.

Justicz answered 15/10, 2021 at 20:16 Comment(1)
But this is about ubi8 images which are redhat specific.Furey
P
2

I ran into this same symptom (locale-gen can't find charmap files) after upgrading from Ubuntu 20.04 to 22.04 in WSL 1. The problem is that there is a bug in WSL 1 that prevents gunzip from running. This is a problem for locale-gen because, at least in Ubuntu 22.04, the charmap files in /usr/share/i18n/charmaps are stored in GZip *.gz format. Apparently, locale-gen depends on gunzip to unzip the charmap files, and when it can't run it, it is stuck.

The solution was

  1. copy UTF-8.gz to the Windows filesystem
  2. unzip it to UTF-8 with a Windows tool (such as 7-zip)
  3. copy UTF-8 back to /usr/share/i18n/charmaps

Then locale-gen worked correctly.

Pardner answered 30/4, 2022 at 16:57 Comment(1)
Thanks for the tip, I encountered same issue when run localedef -i zh_CN -f UTF-8 zh_CN.UTF-8 in docker container (opensuse/leap:latest). And then I installed gzip in the container after see your tip, then localedef successfully generated locale file.Redbird

© 2022 - 2024 — McMap. All rights reserved.