When I always try to install new package I get this message:

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 = "en_GB:en",
    LC_ALL = (unset),
    LC_CTYPE = "en_GB.UTF-8",
    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_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory

My OS is Debian Jessie 8.3 (Mate) using English with French keyboard. When I type locale, I get this:

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

5 Answers 5


Debian ships locales in source form. They need to be compiled explicitly. The reason for this is that compiled locales use a lot more disk space, but most people only use a few of them.

Run dpkg-reconfigure locales as root, select the locales you want in the list (with your settings, you need en_GB and en_US.UTF-8 — I recommend selecting en_US and en_GB.UTF-8 as well) then press <OK>.

Alternatively, edit /etc/locale.gen, uncomment the lines for the locales you want, and run locale-gen as root.

(Note: on Ubuntu, this works differently: run locale-gen with the locales you want to generate as arguments, e.g. sudo locale-gen en_GB en_US en_GB.UTF-8 en_US.UTF-8.)

Alternatively, Debian now has a package locales-all which you can install instead of locales. It has all the locales pre-generated. The downside is that they use up more disk space (112MB vs 16MB).

  • 2
    It worked, but only after I logged out and then logged in again.
    – Forivin
    Commented Aug 16, 2017 at 8:10
  • Worked for me too! Commented Apr 4, 2018 at 19:57
  • editing /etc/locale.gen does't did the job for me (did logout/login), but locale-gen solved my tmux: need UTF-8 locale (LC_CTYPE) problem on Debian 4.9.82
    – eapo
    Commented May 30, 2018 at 21:59
  • 2
    @eapo As I state in my answer, you need to edit /etc/locale.gen and then run locale-gen. Commented May 30, 2018 at 22:30
  • I missed the bit about enabling en_US.UTF-8 as well and your own locale. I found out the hard way then circled back here to make my own answer before realising it was here all along. Commented Feb 9, 2019 at 18:49

The top-rated solution didn't help in my case, so I used this one:

export LC_ALL="en_US.UTF-8"
sudo dpkg-reconfigure locales

After that, I logged out and logged in and error was missing.

  • 3
    Using LC_ALL is strongly discouraged as it overrides everything. Please use it only when testing and never set it in a startup file. as per: wiki.debian.org/Locale Commented Jan 26, 2018 at 9:29

If you're having this issue on a raspberry pi (or other?) and you're getting the error when you ssh to the pi there are 2 other solutions

One is edit /etc/ssh/sshd_config on the pi and comment out the line

AcceptEnv LANG LC_*

for example sudo nano /etc/ssh/sshd_config

After which you should restart the ssh server

sudo systemctl restart ssh

The other is on your client machine (not the pi) edit /etc/ssh/ssh_config (different path from above) and comment out the line

SendEnv LANG LC_*
  • Both of these are uncommented for me but problem still arises. (RPi3, macOS10.14)
    – gosuto
    Commented Oct 9, 2018 at 6:30
  • Commented out the line now. Don't really have the opportunity to test but sounds more logical this way... Thanks.
    – gosuto
    Commented Oct 9, 2018 at 15:38
  • Works on raspberry pi with Debian 10. What is the idea? Throwing away locale settings in a ssh session that is sent from the client host.
    – Timo
    Commented May 15, 2021 at 15:09

These commands saved my life

# echo "LC_ALL=en_US.UTF-8" >> /etc/environment
# echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
# echo "LANG=en_US.UTF-8" > /etc/locale.conf
# locale-gen en_US.UTF-8

You need to install the package locales (or locales-all or the en_GB locale, depending on the Debian version you have).

A workaround not to have such errors: set LANG=C to root, so that it will use no locales.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .