Question

Fixing the locale issue in a clean DigitalOcean droplet

Posted February 21, 2014 37k views
I've read numerous posts about people having problems with the default locale on a clean Digital Ocean droplet with Ubuntu. This manifests in getting errors like: bash: warning: setlocale: LC_ALL: cannot change locale (en_US) There is a quick fix, which is just running locale-gen en_US But. Can't this be fixed in the default Ubuntu image? Apparently en_US is installed as the default locale, but the locale files aren't generated. Am I thinking too simple? Are there any reasons why this can't be included in the default image? Thanks!
1 comment

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
18 answers
this works for me:

edit the file
/etc/environment

add one line with your LANG, like this

LC_ALL="en_US.UTF-8"

save and reboot

  • thanks ! This works perfectly

  • Thanks a lot for this! =)

  • This is moving stuff forward for me! However one question:

    I just add in etc/environment exactly this:

    LC_ALL="en_US.UTF-8"
    

    –>reboot

    Then when I type the ‘locale’ command my list shows like this:

    LANG=en_US.UTF-8
    LANGUAGE=
    LC_CTYPE="en_US.UTF-8"
    LC_NUMERIC="en_US.UTF-8"
    LC_TIME="en_US.UTF-8"
    LC_COLLATE="en_US.UTF-8"
    LC_MONETARY="en_US.UTF-8"
    LC_MESSAGES="en_US.UTF-8"
    LC_PAPER="en_US.UTF-8"
    LC_NAME="en_US.UTF-8"
    LC_ADDRESS="en_US.UTF-8"
    LC_TELEPHONE="en_US.UTF-8"
    LC_MEASUREMENT="en_US.UTF-8"
    LC_IDENTIFICATION="en_US.UTF-8"
    ** LC_ALL=en_US.UTF-8 **
    

    The “ … ” Are missing on the LC_ALL. Is this a problem?

    edited by asb
Are you sure running the following commands doesn't fix it?
sudo locale-gen en_US.UTF-8

sudo dpkg-reconfigure locales
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8

Then run

sudo update-locale

Now run

locale

you shouldn’t see any errors.

For a permanent solution,
Add the above export commands inside ~/.profile

What exact image are you using?
Just create a new droplet with the default ubuntu (12.04.3 x64) and then when you login with the console via ssh and type locale there's an error about this. I can't seem to fix this with running locale-gen en_US or whatever "fix" I could find on StackOverflow or the Ubuntu pages.
Can you post the exact error?
locale
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
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE=UTF-8
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
..and you will see errors like this when you try to set stuff or when an app wants to do something like a set locale.

~# sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password root"
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "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
Err.. Short reply

Thanks juanluis, that fixed it for me :)
The commands from Kamal didn't help at all :/
Previous 1 2 Next