30

I've installed Debian 7 i386 on my VPS (OpenVZ). Everything works fine, except locales - any attempt to install anything shows:

[...]
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LANG = "pl_PL.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
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
[...]

What I've tried:

  1. Generating locales myself - update-locale LC_ALL="pl_PL.UTF-8" - shows: http://www.wklej.org/id/1248438/
  2. apt-get install --reinstall locales http://www.wklej.org/id/1248442/
  3. The same with dpkg-reconfigure locales + setting pl_PL.UTF-8, pl_PL.ISO-8859-2 or even en_US: http://www.wklej.org/id/1248446/
  4. export LC_ALL=pl_PL.UTF-8 (even on root):

    -bash: warning: setlocale: LC_ALL: cannot change locale (pl_PL.UTF-8)
    

Here is what shows locale:

root:~# locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
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
LANG=pl_PL.UTF-8
LANGUAGE=
LC_CTYPE="pl_PL.UTF-8"
LC_NUMERIC="pl_PL.UTF-8"
LC_TIME="pl_PL.UTF-8"
LC_COLLATE="pl_PL.UTF-8"
LC_MONETARY="pl_PL.UTF-8"
LC_MESSAGES="pl_PL.UTF-8"
LC_PAPER="pl_PL.UTF-8"
LC_NAME="pl_PL.UTF-8"
LC_ADDRESS="pl_PL.UTF-8"
LC_TELEPHONE="pl_PL.UTF-8"
LC_MEASUREMENT="pl_PL.UTF-8"
LC_IDENTIFICATION="pl_PL.UTF-8"
LC_ALL=

Nothing interesting found in /var/log. Even changing repo to official + purge and manual installation locales doesn't solve my problem, which manifests itself on each fresh installation of Debian 7.

21

It seems that no locale is generated. Have you selected pl_PL.UTF-8 properly in dpkg-reconfigure locales by pressing space in the corresponding line?

If yes, the line

pl_PL.UTF-8 UTF-8

in /etc/locale.gen is not commented (= does not start with #). If you need to fix this, you need also to run locale-gen to generate the locales. Its output should be:

Generating locales (this might take a while)...
   pl_PL.UTF-8... done
Generation complete.

If it does not output the locales you want to generate, there seems to be something wrong with your system. One reason could be that you have localepurge installed. If there are no files in /usr/share/locale/pl/LC_MESSAGES or /usr/share/locale/pl_PL/LC_MESSAGES this is the case or your system is broken.

  • 1
    It works! Selected position in /etc/locale.gen was still commented, don't know why (yes, I remember about spacebar) - maybe something is wrong with CHMOD. Thanks! – luke_g Jan 24 '14 at 13:34
  • 1
    Note that -plow is the default, so can be omitted. You only need to call dpkg-reconfigure, which will call locale-gen after you tick the entry you want. – Stéphane Chazelas Jan 24 '14 at 14:25
  • @StephaneChazelas thanks, I removed it from the answer and clarified the usage of locale-gen. – jofel Jan 24 '14 at 15:16
  • Another possibility is if you have configured your system etc for en_US but your /etc/locale.gen has only uncommented en_GB. I noticed this mistake in this thread here unix.stackexchange.com/q/287716/16920 Please, add it to the throubleshoot strategy too. – Léo Léopold Hertz 준영 Jun 22 '16 at 20:21
10

first:

sudo apt-get purge locales

then:

sudo aptitude install locales

and the famous:

sudo dpkg-reconfigure locales

This rids the system of locales, then re-installs locales and downgrades libc6 from 2.19 to 2.13 which is the issue. Then configures locales again.

  • Seems to help but the next apt-get dist-upgrade will break it again. – ceving Sep 28 '14 at 13:44
  • Why would it break it? At that point shouldn't locales be compatible with the libc6 being used? My libc6 was changed to use some other program. I've downgraded it back to the default libc6 version so my system works properly. At which point it should be very much compatible with an apt-get dist-upgrade – tkjef Oct 1 '14 at 14:38
  • 1
    An apt-get install locales installed the locales on my Docker debian container. – Stephane Nov 20 '16 at 10:54
5

The quick and easy way (although it will mean more disk used than others):

apt install locales-all
0

try run

locale -a

if you got

locale: Cannot set LC_CTYPE to default locale: No such file or directory
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

The solution for this situation is to install the package locales (from glibc package [1] ) in debian flavor or glibc-all-langpacks CentOS/Fedora

[1] https://tracker.debian.org/pkg/glibc

  • glibc-locale package does not exist in Debian – Yajo May 23 '17 at 8:46
  • should be package locale ... fixed – Sérgio May 23 '17 at 12:45

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.