perl: warning: Setting locale failed


On a CentOS 8.2 system, I have a locale error while being connected in ssh from a macOS Catalina:

[[email protected] ~]$ cat /etc/redhat-release 
CentOS Linux release 8.2.2004 (Core) 

I was just running exiftool, showing a perl warning “Setting locale failed”:

[[email protected] m]$ exiftool
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_CTYPE = "UTF-8",
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8”)

I have the same error when I check with the “locale” command:

[[email protected] ~]$ locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LC_CTYPE=UTF-8
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

To fix my issue, I’ve set-up the LC_ALL environment variable:

[[email protected] ~]$ echo "export LC_ALL=\"en_US.UTF-8\"" >> ~/.bashrc

Double check that you have added the LC_ALL:

[[email protected] ~]$ grep LC_ALL ~/.bashrc 
export LC_ALL="en_US.UTF-8"

Unlog/relog of your session or just source the bash file:

[[email protected] ~]$ source ~/.bashrc

Locale command is now working:

[[email protected] ~]$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8


A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

EN | FR | ES

Search