Problem

During apt-get update (which tries to install or update any Perl application) you get the following error message:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),

Analysis

When installing Debian or Ubuntu, the locales may not be completely set. During the installation of Perl applications (such as Nagios), the warning, perl: warning: Setting locale failed, may be displayed.

Solution

To get rid of the messages I had to run this command:

# locale-gen en_US en_US.UTF-8 sk_SK sk_SK.UTF-8

Note: Change “sk_SK” to your locale/code.

then

# dpkg-reconfigure locales

The following screen asks which locales to generate and which one to choose as the default one:

After hitting Ok the locales are generated an everything should be set.

References

  1. Thread: perl: warning: Setting locale failed.
  2. Perl warning Setting locale failed in Debian
perl: warning: Setting locale failed.
Tagged on: