1

Failing to generate C.UTF-8 locale on CentOS6 :

# 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=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=
# localedef -v -c -i C -f UTF-8 C.UTF-8
cannot open locale definition file `C': No such file or directory

How can I do that on CentOS6 ?

1 Answer 1

1

You would first need to provide a compatible /usr/share/i18n/locales/C file, because RHEL / CentOS 6.x does not have one for the C locale.

I think when RHEL 6 was new, RedHat's recommendation used to be "use en_US.utf8 instead". And indeed, in RHEL 6 the en_US locale provides 24-hour time representation, if that's what you're after.

Also, RHEL 6 seems to prefer the .utf8 form to specify the UTF-8 character encoding instead of .UTF-8, as evidenced both locale -a and localedef --list-archive.

3
  • CentOS7 also complains saying cannot open locale definition file "C': No such file or directory", I think I'll stick using LANG=en_US.utf8 in my .bash_profile. Thanks.
    – SebMa
    Jul 20, 2022 at 16:02
  • 1
    How does one "provide a compatible /usr/share/i18n/locales/C file"? I have exactly same problem with CentOS 7.
    – arrowd
    Mar 3, 2023 at 11:59
  • @arrowd Your options would be to either download the source RPM that builds the glibc-common package (which includes the /usr/share/i18n/locales/* files), and build your own definition for the C.UTF-8 locale, or if there is another locale that has suitable contents but wrong name, using /usr/share/locale/locale.alias to make C.UTF-8 refer to a suitable existing locale. Note that edits to /usr/share/locale/locale.alias will get overwritten whenever glibc-common is updated, since it is not marked as a configuration file within the RPM package metadata.
    – telcoM
    Mar 3, 2023 at 12:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .