Debian – Problem with locale: “Setting locale failed.”

debianlocale

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),
LC_CTYPE = "UTF-8",
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.
Done.

How can I resolve it?

Best Answer

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).

Related Question