Fix locale setting on Ubuntu EC2 instances

Posted by Matthias Schmidt on March 29, 2013

After booting a fresh EC2 instance with Ubuntu 12.10 this showed up right after login:

WARNING! Your environment specifies an invalid locale.
This can affect your user experience significantly, including the
ability to manage packages.

And when running some apt-get commands I got this:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_CTYPE = "de_DE.UTF-8",
    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_ALL to default locale: No such file or directory

There are plenty of supposed solutions out there but none worked for me but this one:

# add this line to /etc/environment; then reboot


There are some alternative commands you could try:

$ sudo locale-gen de_DE.UTF-8 en_US.UTF-8
$ sudo apt-get install language-pack-en