This article describes how to fix this warning “Failed to set locale, defaulting to C.UTF-8” in CentOS 8 /RHEL 8 .
A locale is a set of basic system parameters that define:
- Variant preferences
Note: On Linux , locale identifiers are defined by ISO/IEC 15897.
For example: United state of america (US) English using the UTF-8 encoding is en_US.UTF-8.
Fixing The Problem
- Set system locale, use the localectl command. run the following command for english united state
localectl set-locale LANG=en_US.UTF-8
- Verify if the system locale has been set or not with localectl command.
[root@unixcop ~]# localectl System Locale: LANG=en_US.UTF-8 VC Keymap: us X11 Layout: us [root@unixcop ~]#
- Try to install a package
For example installing mysql service
As shown above, the warning still existed. because the language packages are missing.
- Install all language packages by the glibc-all-langpacks package that contains all locales.
dnf install -y glibc-all-langpacks langpacks-en
Note: To install locale individually, run the following command by replacing en with the locale-code you want.
Example to install french locale with its code fr :
dnf install glibc-langpack-fr
We illustrated how to fix the error “Failed to set locale, defaulting to C.UTF-8” in CentOS 8 or RHEL 8.