Debian Jessie: Perl warning Setting locale failed

By | May 13, 2015

While upgrading and installing packages on a fresh Debian Jessie droplet on DigitalOcean today, the warning message  perl: warning: Setting locale failed was displayed. This happens because locales are/may not be completely set.

By executing the ‘locale’ command, this can be ascertained. The first three lines clearly describe it.

root@www:~# 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=en_US.UTF-8
LANGUAGE=
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=

This can be easily sorted out by creating a locale file manually as described below

root@www:~# localedef -i en_US -f UTF-8 en_US.UTF-8

Lets verify by re-executing the locale command

root@www:~# locale
LANG=en_US.UTF-8
LANGUAGE=
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=

Great so the locale error message has gone. Henceforth the warning message perl: warning: Setting locale failed will not be displayed while installing or upgrading packages.

Leave a Reply

Your email address will not be published. Required fields are marked *