Fixing invalid locale settings in Debian 8

You might have met this before. Indeed! Very annoying. This is due to unset of locale variable in Debian environment specifically for Perl applications.


Can't set 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),
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").
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

To solve the above issue you need

  • Generate locale (if needed). There is locale-gen tool under Debian.
  • Set environment variables (via export).
  • Reconfigure locales by dpkg-reconfigure tool.

Here we go with step-by-step shell commands:


export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
dpkg-reconfigure locales

Hope it helps, but if there are any questions - feel free to use the form below!


In short, this is about:
#locale issue

Start discussion:
Related articles: