Thread: initdb.exe Fails on Windows When Password File Path Contains Non-ASCII Characters

Hi,

The postgresql windows installer packaged by EDB, creates the postgresql instance on the fly.
It creates a temporary file to store the password and then deletes it once the initdb is run successfully.
But a user reported the initdb fails. On debugging it was found that, it occurs because the username in the
%TEMP% contains the non-ascii characters as shown in the example below
initdb.exe --pgdata="C:\Program Files\PostgreSQL\17\data" --username=postgres --encoding=UTF8 --pwfile="C:\Users\玛妮卡\AppData\Local\Temp\passwdXXX" --auth=scram-sha-256 initdb: error: could not open file "C:\Users\???\AppData\Local\Temp\psswrdXXXX" for reading: No such file or directory ... .... It seems that initdb.exe does not correctly handle paths containing Unicode characters, replacing them with ???
in the error message. I want to ask if this is the expected behaviour of initdb.exe? When the user temp location is replaced with system temp (c:\windows\temp) the error goes away.
Any suggestions if the installer should use this path to create the password file?


-----------------------------
Thanks & Regards
Manika Singhal
EDB India

On Tue, Mar 11, 2025 at 5:12 PM Manika Singhal <manika.singhal@enterprisedb.com> wrote:
Hi,

The postgresql windows installer packaged by EDB, creates the postgresql instance on the fly.
It creates a temporary file to store the password and then deletes it once the initdb is run successfully.
But a user reported the initdb fails. On debugging it was found that, it occurs because the username in the
%TEMP% contains the non-ascii characters as shown in the example below 
 
initdb.exe --pgdata="C:\Program Files\PostgreSQL\17\data" --username=postgres --encoding=UTF8 --pwfile="C:\Users\玛妮卡\AppData\Local\Temp\passwdXXX" --auth=scram-sha-256
 
initdb: error: could not open file "C:\Users\???\AppData\Local\Temp\psswrdXXXX" for reading: No such file or directory
 
It seems that initdb.exe does not correctly handle paths containing Unicode characters, replacing them with ???
in the error message. I want to ask if this is the expected behaviour of initdb.exe?
 
When the user temp location is replaced with system temp (c:\windows\temp) the error goes away.
Any suggestions if the installer should use this path to create the password file?



sending again with corrected spacing. Sorry for the inconvenience!



-----------------------------
Thanks & Regards
Manika Singhal
EDB India