10 Jan 2014, 14:55

AWS Locale

Share

Every time I start a new EC2 Ubuntu instance, I’m confronted with the following warning when I ssh in:

_____________________________________________________________________
WARNING! Your environment specifies an invalid locale.
 This can affect your user experience significantly, including the
 ability to manage packages. You may install the locales by running:

   sudo apt-get install language-pack-UTF-8
     or
   sudo locale-gen UTF-8

To see all available language packs, run:
   apt-cache search "^language-pack-[a-z][a-z]$"
To disable this message for all users, run:
   sudo touch /var/lib/cloud/instance/locale-check.skip
_____________________________________________________________________

Furthermore, a variety of package installations fail with some complaint related to the locale, the default language, or both. And for some reason the advice to install relevant language packs is not helpful.

It turns out that there are some of environment variables (LANGUAGE, LC_CTYPE and LC_ALL to be specific) that are not set properly.

The advice to install language packs assumes that these environment variables are set to a language that’s not installed. However, in the case of a new EC2 instance, these variables are not set at all.

An easy way to get the warnings to go away is to edit the file /etc/default/locale so that these variables always get set. I’ve found that the default installation only sets LANG.

/etc/default/locale

LANG=en_US.UTF-8
LANGUAGE=en_US
LC_CTYPE=en_US.UTF-8
LC_ALL=en_US.UTF-8

As always, it’s also a good idea to make sure you have the latest and greatest packages:

$ sudo apt-get update
$ sudo apt-get upgrade

And finally, while we’re at it, why not set the timezone?

$ sudo dpkg-reconfigure tzdata

Next time I need to set up a new EC2 instance, I’ll come read my own blog and know exactly what to do.