All operating systems uses some locale settings to properly interpret language related data. In Linux this settings are called as
locale and used even without GUI or desktop environment. They are generally configured during installation of the operating system but also changed after installation. “Perl warning Setting locale failed” is mostly occurring error after installation. Which is caused by
locale miss configuration. In this tutorial we will look how to solve this error.
“perl: warning: Setting locale failed.” Error
The error will be look like below.
Debian, Ubuntu, Mint, Kali
The most practical and easy solution is regenerating locales. We will use
locale-gen and specify the locate type we want to set and regenerate. We need
sudo privileges for this.
$ sudo locale-gen en_US.UTF-8
Another way to specify locales explicitly is using
export with bash variables and than call
dpkg-reconfigure on locales.
$ sudo dpkg-reconfigure locales
Fedora, CentOS, RHEL
In CentOS way we can use
localectl command and
set-locale option for this.
$ sudo localectl set-locale LANG=en_GB.utf8
Setting Locales Explicitly
We can also set locales explicitly. We will use
localdef command and specify the locales we want to use.
$ sudo localedef -i en_US -f UTF-8 en_US.UTF-8