0

I noticed on some VPS's, locales is not installed by default so dpkg-reconfigure locales will only throw an error saying that locales is not installed.

I want to do apt-get install locales, I've done this a couple times and I know this sets up the locales, but it would also start to throw warnings despite configuring itself to work, hence every package thereafter will not complain with something like:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    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_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

But should I do something like edit /etc/environment and manually set environment variables like LC_ALL to en_US.UTF-8 to make sure the installation of locales goes fine? Or does it not even matter because I'll only install it one time and despite it throwing warnings when trying to install itself, since it will work after that, not worry about it?

meder omuraliev
  • 1,701
  • 3
  • 20
  • 30

3 Answers3

4

I'm calling bullshit on the 'this doesn't matter' answers. for one, the constant errors in the console unable to set the locale is extremely annoying. but this is not all, some things really will not work.

I just solved this on a new VPS. a short summary:

locales need to be generated before they can be used. I'm not sure about other distributions so following is a summary for debian/ubuntu.

first just try to run dpkg-reconfigure locales. this should set it up on some debian distros. but I stumbled at some that don't. this probably means that you need to reconfigure smth else there but I din't find it so I figured out a more manual way to do the same:

older debian/ubuntu stored the supported locales in /etc/locale.gen, newer store it in /var/lib/locales/supported.d/local

you can tell which one you have by checking if the directory /var/lib/locales/supported.d/ exists or not.

to generate en_US.UTF-8 locale put the following string in this file: en_US.UTF-8 UTF-8 then run locale-gen to generate the locales.

you can confirm that generation worked by running locale -a to list all available locales.

now you need to configure your shell to set the locales. just edit /etc/default/locale and put the following there: LANG=en_US.UTF-8

now you can exit your shell and come back to check that echo $LANG prints en_US.UTF-8

that should be it.

Vitaly Kushner
  • 1,187
  • 9
  • 8
1

I personally have yet to see an error when having an unset locale, but I don't deal with unicode or multilingual systems much, so I'm not certain if I work as a good sample for its urgency.

As for setting the locale, the guaranteed way to set it on your system is to edit /etc/locale.gen so that the locales you're presently in are uncommented, and then running

# genlocale

under root. Also, this method is generally cross platform for all linux systems.

Mies
  • 206
  • 1
  • 2
1

You do not have to worry about these warning messages, they are not about the actual installation or configuration but about the presentation of messages to you (and very rarely anything serious in that department either).

Mikael Auno
  • 942
  • 6
  • 12