Search code examples
ruby-on-railspostgresqlubuntulocale

Postgres locale error on remote server


I am using a remote server from Digital Ocean set up with Ubuntu 14.04, Rails and am having issues with missing locale settings. I have googled the issue and have tried them which didn't work for me.

Examples

sudo locale-gen en_US en_US.UTF-8
sudo dpkg-reconfigure locales 

Error received when trying to create a new Postgres user

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")

My -locale settings

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=

Solution

  • It seems your LANGUAGE is not set.

    You can try

    export LANGUAGE="en_US.UTF-8"
    echo 'LANGUAGE="en_US.UTF-8"' >> /etc/default/locale
    echo 'LC_ALL="en_US.UTF-8"' >> /etc/default/locale
    

    This is nice article about how to configure locale in Ubuntu.


    Edit: I noticed now it is about Digital Ocean. Try to edit environment instead

    gksudo gedit /etc/environment
    

    and add LANGUAGE="en_US.UTF-8" and LC_ALL="en_US.UTF-8". I hope it will help.