Postgres error upgrading from 3.3 to 3.4 caused by locale issues

I think I have an issue in similar manner :confused:

I have updated the forum via admin interface and it did not start. So I tried to rebuild from console.

my env is set to Polish:

env:
  LANG: pl_PL.UTF-8

Changing this to anything does not help.

The locales are there:

ubuntu@vps:/var/discourse/containers$ locale -a
C
C.UTF-8
POSIX
en_US.utf8
pl_PL.utf8

This is what has been there for the past 2 years…

But I get this fail on rebuild:

failed to set locale!
[error] character map file `UTF-8' not found: No such file or directory
failed to set locale!
[error] default character map file `ANSI_X3.4-1968' not found: No such file or directory
failed to set locale!
[error] character map file `UTF-8' not found: No such file or directory
failed to set locale!
[error] default character map file `ANSI_X3.4-1968' not found: No such file or directory
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = "en_US.UTF-8",
        LC_ALL = "en_US.UTF-8",
        LANG = "pl_PL.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
I, [2025-01-06T10:08:48.737950 #1]  INFO -- : Generating locales (this might take a while)...
  en_US.UTF-8... done
  pl_PL.UTF-8... done
Generation complete.

And then it starts looping with these errors:

2025-01-06 10:09:48.880 UTC [47] FATAL:  database locale is incompatible with operating system
2025-01-06 10:09:48.880 UTC [47] DETAIL:  The database was initialized with LC_COLLATE "en_US.UTF-8",  which is not recognized by setlocale().
2025-01-06 10:09:48.880 UTC [47] HINT:  Recreate the database with another locale or install the missing locale.