3

On a new copy of Ubuntu 11.04 server I am trying to install PostgreSQL server by apt-get install postgresql. But in the end of installation log I saw:

Error: could not create default cluster. Please create it manually with

  pg_createcluster 8.4 main --start

When I ran this command I saw this message:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US:en",
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").
Error: The locale requested by the environment is invalid.

And no PostgreSQL server started :(

What I need to do to become happy on this?

defmthd
  • 61
  • 1
  • 7

4 Answers4

6

The accepted answer didn't help me; if there are others like me please read below.

I traced the problem to pg_upgradecluster explicitly unsetting LC_ALL. This made Perl fail whichever way I was playing with the other environment variables.

So what I did is that I simply commented line 352 in /usr/bin/pg_upgradecluster:

#delete $ENV{'LC_ALL'};

This did the trick. Of course, this will only work if you're an average Joe with en_US.UTF-8 in all clusters and don't use any fancy encodings that you need to preserve.

Ilya Semenov
  • 191
  • 1
  • 8
  • 1
    Same issue on Ubuntu 14.04 while upgrading from 9.1 to 9.3. The accepted answer didn't help me either. After commenting the line upgrade run just fine. Thanks for this suggestion. – Burnash Jun 03 '15 at 23:30
  • Wow, this saved a lot of headaches for me today! Thanks a lot! I would like to know though why is pg_upgradecluster unsetting LC_ALL. – Stelian Iancu Jan 12 '16 at 09:41
2

This lines are helped me:

echo 'LANGUAGE="en_US.UTF-8"' >> /etc/default/locale
echo 'LC_ALL="en_US.UTF-8"' >> /etc/default/locale
defmthd
  • 61
  • 1
  • 7
2

The current environment variables have effect as well. Use the command

locale

to see what is seen by Postgres, and update using export statements, e.g.:

export LANGUAGE="en_US.UTF-8"
1

Luckily for you this is an issue I had to look up my notes on, but you asked it in September 2011.

Check these links - Enlist the help of Google Translate

http://www.thomas-krenn.com/de/wiki/Perl_warning_Setting_locale_failed_unter_Debian

http://www.thomas-krenn.com/de/wiki/Locales_unter_Ubuntu_konfigurieren

https://help.ubuntu.com/community/Locale#List_current_settings

vfclists
  • 1,632
  • 5
  • 22
  • 37