Failed to set locale, defaulting to C

Issues related to applications and software problems and general support
Post Reply
eneubauer
Posts: 6
Joined: 2019/10/30 14:11:42

Failed to set locale, defaulting to C

Post by eneubauer » 2019/10/30 15:12:17

Hi there,
I just finished my first CentOS 8 installation. I did a network installation and where I installed only a base system (not sure if this is relevant), as I want to run a LAMP or LEMP setup.

Whenever I run any yum command I get the message:

Code: Select all

Failed to set locale, defaulting to C
I googled the error and first I found something mentioning that you have to reinstall glibc-common, which I tried.
Then I found something mentioning having to install glibc-langpack-en, which I tried as well to no avail.

Code: Select all

[root@localhost ~]# localectl status
   System Locale: LANG=en_US.utf8
       VC Keymap: us
      X11 Layout: us

Code: Select all

[root@localhost ~]# cat /etc/locale.conf 
LANG=en_US.utf8

Code: Select all

[root@localhost ~]# localectl list-locales
C.utf8
en_AG
en_AU
en_AU.utf8
en_BW
en_BW.utf8
en_CA
en_CA.utf8
en_DK
en_DK.utf8
en_GB
en_GB.iso885915
en_GB.utf8
en_HK
en_HK.utf8
en_IE
en_IE.utf8
en_IE@euro
en_IL
en_IN
en_NG
en_NZ
en_NZ.utf8
en_PH
en_PH.utf8
en_SC.utf8
en_SG
en_SG.utf8
en_US
en_US.iso885915
en_US.utf8
en_ZA
en_ZA.utf8
en_ZM
en_ZW
en_ZW.utf8

Code: Select all

[root@localhost ~]# localectl set-locale en_US.utf8
[root@localhost ~]# localectl status
   System Locale: LANG=en_US.utf8
       VC Keymap: us
      X11 Layout: us
Not really sure what the next steps are to resolve this issue, perhaps somebody has been able to resolve this?

User avatar
TrevorH
Forum Moderator
Posts: 27152
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Failed to set locale, defaulting to C

Post by TrevorH » 2019/10/30 15:41:30

Did you logout and back in after making those changes?
CentOS 6 will die in November 2020 - migrate sooner rather than later!
CentOS 5 has been EOL for nearly 3 years and should no longer be used for anything!
Full time Geek, part time moderator. Use the FAQ Luke

eneubauer
Posts: 6
Joined: 2019/10/30 14:11:42

Re: Failed to set locale, defaulting to C

Post by eneubauer » 2019/10/31 10:28:17

Yes, I just rebooted the whole machine.

touchwood
Posts: 3
Joined: 2019/09/23 19:48:48

Re: Failed to set locale, defaulting to C

Post by touchwood » 2019/10/31 12:49:00

Did you try to set it to "en_US.UTF-8" instead of "en_US.utf8" (like mentioned in localectl manual pages)?

eneubauer
Posts: 6
Joined: 2019/10/30 14:11:42

Re: Failed to set locale, defaulting to C

Post by eneubauer » 2019/10/31 14:18:34

Code: Select all

[root@centos ~]# localectl set-locale en_US.UTF-8
[root@centos ~]# reboot
Just to be sure (I feel like in Windows :P)

Code: Select all

[root@centos ~]# localectl status
   System Locale: LANG=en_US.UTF-8
       VC Keymap: us
      X11 Layout: us
[root@centoscentos ~]# yum update
Failed to set locale, defaulting to C
But I just found the following:

Code: Select all

[root@centos ~]# locale
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=de_DE.UTF-8
LC_TIME=de_DE.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=de_DE.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=de_DE.UTF-8
LC_NAME=de_DE.UTF-8
LC_ADDRESS=de_DE.UTF-8
LC_TELEPHONE=de_DE.UTF-8
LC_MEASUREMENT=de_DE.UTF-8
LC_IDENTIFICATION=de_DE.UTF-8
LC_ALL=
EDIT:
So I installed strace and did the following:

Code: Select all

[root@centos ~]# strace -ff locale 2>&1 | grep openat
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/usr/lib/locale/en_US.UTF-8/LC_CTYPE", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/locale/en_US.utf8/LC_CTYPE", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/usr/lib64/gconv/gconv-modules.cache", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/lib/locale/en_US.UTF-8/LC_MESSAGES", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/locale/en_US.utf8/LC_MESSAGES", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/usr/lib/locale/en_US.utf8/LC_MESSAGES/SYS_LC_MESSAGES", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/usr/lib/locale/de_DE.UTF-8/LC_IDENTIFICATION", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/locale/de_DE.utf8/LC_IDENTIFICATION", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/locale/de_DE/LC_IDENTIFICATION", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/locale/de.UTF-8/LC_IDENTIFICATION", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/locale/de.utf8/LC_IDENTIFICATION", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/locale/de/LC_IDENTIFICATION", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en_US.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)

evolutive
Posts: 1
Joined: 2019/10/31 14:26:57

Re: Failed to set locale, defaulting to C

Post by evolutive » 2019/10/31 14:52:56

I'm having a similar problem, trying to reinstall

Code: Select all

[root@vmi192876 transfer]# yum reinstall glibc-common
Says:
Installed package glibc-common-2.28-42.el8.1.x86_64 (from anaconda) not available.
Error: No packages marked for reinstall.

in order to use:

Code: Select all

localedef -i en_US -f UTF-8 en_US.UTF-8
which says:

failed to set locale!
[error] character map file `UTF-8' not found: No such file or directory

Any solution?

eneubauer
Posts: 6
Joined: 2019/10/30 14:11:42

Re: Failed to set locale, defaulting to C

Post by eneubauer » 2019/10/31 15:09:37

So I've tried a few more things now:

Searching for the following error message:

Code: Select all

locale: Cannot set LC_ALL to default locale: No such file or directory
Resulted in a github issue for a centos docker container, where it was recommended to run the following command:

Code: Select all

localedef -v -c -i en_US -f UTF-8 en_US.UTF-8
This command also failed for me, so a strace revealed it is trying to access the following files:

Code: Select all

[...]
openat(AT_FDCWD, "/usr/share/i18n/charmaps/UTF-8", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/i18n/charmaps/UTF-8.gz", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/i18n/charmaps/UTF-8.bz2", O_RDONLY) = -1 ENOENT (No such file or directory)
[...]
So I ran:

Code: Select all

[root@centos ~]# yum whatprovides '*/UTF-8.gz'
Failed to set locale, defaulting to C
Last metadata expiration check: 0:08:17 ago on Thu Oct 31 10:47:29 2019.
glibc-locale-source-2.28-42.el8_0.1.x86_64 : The sources for the locales
Repo        : BaseOS
Matched from:
Filename    : /usr/share/i18n/charmaps/UTF-8.gz
Installed the package, reran the localedef command, which succeeded now.
However I believe there are still a few files missing files, as the locale command and any yum command still show the same errors

eneubauer
Posts: 6
Joined: 2019/10/30 14:11:42

Re: Failed to set locale, defaulting to C

Post by eneubauer » 2019/10/31 15:32:15

I found the following two bug reports that might be relevant, so I'm posting them here for future reference:
https://bugs.centos.org/view.php?id=16483
https://bugs.centos.org/view.php?id=16472

User avatar
TrevorH
Forum Moderator
Posts: 27152
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Failed to set locale, defaulting to C

Post by TrevorH » 2019/10/31 15:51:39

evolutive wrote:
2019/10/31 14:52:56
I'm having a similar problem, trying to reinstall
Please don't hijack threads. That has nothing to do with this problem. Your problem with the reinstall is due to a problem with the original install containing packages on the DVD with the wrong dist tag (el8.1) that appear to be newer than the correct ones that are now in the yum repos with dist tags of el8_0.1. You can't reinstall the wrong ones because they have been excluded from the online repo metadata. I think you will need to downgrade to the actually-newer packages.

Also localedef doesn't appear to work like you think it does according to my reading of the man page.
CentOS 6 will die in November 2020 - migrate sooner rather than later!
CentOS 5 has been EOL for nearly 3 years and should no longer be used for anything!
Full time Geek, part time moderator. Use the FAQ Luke

eneubauer
Posts: 6
Joined: 2019/10/30 14:11:42

Re: Failed to set locale, defaulting to C

Post by eneubauer » 2019/10/31 16:08:44

I did another test installation and I can't reproduce the error in the new VM.
You can mark this thread resolved.

I guess something went wrong while installing my VM, I might have put my workstation into sleep while the VM was still installing... ?

Post Reply

Return to “CentOS 8 - General Support”