25

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
FedericoY
  • 253
  • 1
  • 3
  • 4

3 Answers3

32

You need to install these packages

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

and then re-run localedef command

Mina Alber
  • 336
  • 3
  • 3
9

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

Tobias J
  • 19,813
  • 8
  • 81
  • 66
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.

Josh
  • 1,493
  • 1
  • 13
  • 24
AlbertB
  • 23
  • 3
  • 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. – LiuYan 刘研 Jun 09 '22 at 09:01