Purpose: Lot of time when you upgrade/downgrade Debian OS, you might end up getting some locale warnings (or error) messages on your system whenever you give any commands like “man cp”, “apt-get upgrade”, etc.  Many people try tirelessly to get rid of those messages but they can’t seem to even after trying many solutions found on the Internet.  In this short blog entry we will see how to get rid of these locale/perl annoying error messages.

If you are getting any of the following warning/error messages then most probably following the solution that is suggested will take care of your problem on Debian Lenny.

Warnings/Error Messages:

can't set the locale; make sure $LC_* and $LANG are correct


perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
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

Solution #1

First give the following commands:

apt-get update
apt-get belocs-locales-bin belocs-locales-data
apt-get install belocs-locales-bin belocs-locales-data

Note: The above command will most likely remove the package “locales” since they are mutually exclusive.

Now edit the following file:

debian:~# nano /etc/locale.gen

and make sure that you have at least one of the locales selected (un-commented) in the file:
# en_US ISO-8859-1
# en_US.ISO-8859-15 ISO-8859-15
en_US.UTF-8 UTF-8
# en_ZA ISO-8859-1
# en_ZA.UTF-8 UTF-8

Save and quit.

Now give the following command:

debian:~# locale-gen
Generating locales...
en_US.UTF-8... done
Generation complete.

With this your locale/perl warnings should go away.

Solution #2

In case if you are still not able to get rid of these messages, then follow these steps:

apt-get update
apt-get install locales
dpkg-reconfigure locales

and select en_US.UTF-8 as shown below:

Configure locales

Configure locales

and then

locales en_US.UTF-8

locales en_US.UTF-8

After hitting “OK” you will see something like this:

Generating locales (this might take a while)...
en_US.UTF-8... done
Generation complete.

As usual, please leave a comment/feedback if you have any. Also please don’t forget to rate this post below.

Be Sociable, Share!