I am trying to upgrade a Postgresql 13 database to version 15 using the command pg_upgradecluster 13 main but it keeps failing with this message:
Stopping old cluster...
Restarting old cluster with restricted connections...
Notice: extra pg_ctl/postgres options given, bypassing systemctl for start operation
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 a fallback locale ("en_US.UTF-8").
Error: The locale requested by the environment is invalid:
LANG: en_US.UTF-8
LC_CTYPE: UTF-8
Error: Could not create target cluster
When I run the locale command, I get the following:
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
I get the same values I do this:
sudo -u postgres -i
locale
The contents of /etc/default/locale:
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
So where is LC_CTYPE: UTF-8 coming from?
I have executed dpkg-reconfigure locales as well, and only en_US.UTF-8 UTF-8 is selected, and it's set as the default.
UPDATE: the following command worked:
env -i LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 pg_upgradecluster 13 main
But I am still very surprised why this is even necessary on a pretty standard Debian install?
env LC_CTYPE="en_US.UTF-8" pg_upgradecluster 13 main. But perhaps it's complaining thaten_US.UTF-8itself isn't installed. You can check withsudo dpkg-reconfigure localesdpkg-reconfigure localesas well, and onlyen_US.UTF-8 UTF-8is selected, and it's set as the default. It's just so weird that this override is even necessary, I have no idea where the error is coming from.locale, right?