I have a problem with locale and I can't found any solution that works!

Every tutorial is similar to this: Perl warning Setting locale failed in Debian.

This is the problem with locale:

pi @ server [~]:
$ > sudo deluser --remove-home cm22
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_GB.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Looking for files to backup/remove ...
Removing user `cm22' ...
Warning: group `cm22' has no more members.

How can I resolve it?

  • Can you post the output of locale, locale -a and env | grep -e LANG -e LC_? Nov 20, 2014 at 13:04
  • The output is: pi @ server [~]: $ > locale -a and env | grep -e LANG -e LC_? locale: Cannot set LC_CTYPE to default locale: No such file or directory
    – anerdev
    Nov 20, 2014 at 19:26

3 Answers 3


Debian saves network bandwidth by shipping locale definitions in a form that isn't directly usable, where information that is shared between locales (e.g. en_US and en_CA are very similar) is stored in a single file. Usable locale definitions must be generated on each machine. To save CPU time and disk space, only locales requested by the system administrator are generated.

Run the following command as root to configure the set of locales to generate:

dpkg-reconfigure locales

Alternatively, edit the file /etc/locale.gen and comment out the lines corresponding to the locales you want (lines beginning with # are comment lines). For example, if you want the en_GB.UTF-8 locale, you need to have a line containing

en_GB.UTF-8 UTF-8

Once you've edited /etc/locale.gen, run locale-gen to regenerate the locale definitions.

The value UTF-8 that you've set for LC_CTYPE is invalid. You need to use a valid locale name, e.g. LC_CTYPE=en_GB.UTF-8. You can leave LC_CTYPE unset: it'll default to the value of LANG. Though I rather recommend to leave LANG unset and set LC_CTYPE=en_GB.UTF-8 and LC_TIME=en_GB.UTF-8 (LC_MESSAGES effectively defaults to English, if you were using another language then you should set it as well).

  • I change /etc/locale.gen. But how set LC_CTYPE ? Thank you
    – anerdev
    Dec 3, 2014 at 19:16
  • 1
    @anerdev Edit whichever file has the bad definition of LC_TYPE to fix it. It could be in your home directory or under /etc. Try grep -s LC_CTYPE ~/.* || grep -rs LC_CTYPE /etc to find it. Dec 11, 2014 at 23:53

If you have not explicitly set LC_CTYPE, type :

export LC_CTYPE="en_US.UTF-8"

(replace en_US, for your desired LANG/CTYPE required definition)

Although verbose, typing:

locale LC_CTYPE

will provide the current setting value.

See locale for further reading


I had the same issue on a virgin copy of raspbian.

export LC_ALL="en_US.UTF-8"

sudo dpkg-reconfigure locales

You must log in to answer this question.

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