The following command fails on windows 10:
postgresql-11.3-1-windows-x64.exe --unattendedmodeui minimal --mode unattended --prefix "C:\PostgreSQL11" --datadir "C:\PostgreSQL11\data" --serverport 5432 --superpassword mypassword
A popup appears with the error message: "error.install.directory.nondefault"
The following command line however succeeds:
postgresql-11.3-1-windows-x64.exe --unattendedmodeui minimal --mode unattended --serverport 5432 --superpassword mypassword
Is there a way to install PostgreSQL 11 on Windows in a specific directory?
The error which you are seeing in the bitrock installer is not expanding the actual message i.e, The chosen instllation directory exists and is non-empty. Please choose a different directory.
The reason for not expanding the abvove error message is, I think you are installing in diffrent lanuage rather than en by default it will be en(english). If you use installation in different lanuage apart from default language that is "en" then you will se the below error.
Installation with diferrent lanuage:
postgresql-11.3-1-windows-x64.exe --unattendedmodeui minimal --mode unattended --prefix “C:\PostgreSQL11” --datadir “C:\PostgreSQL11\data” --serverport 5432 --superpassword test --installer-language -es
Installation with defaul lanuage(en) english:
postgresql-11.3-1-windows-x64.exe --unattendedmodeui minimal --mode unattended --prefix “C:\PostgreSQL11” --datadir “C:\PostgreSQL11\data” --serverport 5432 --superpassword test --installer-language -en
The autal error says that "C:\PostgreSQL11" installation directory exit but and is non-empty. You need to have empty directory i.e, "C:\PostgreSQL11" if any file/folder exit at location "C:\PostgreSQL11" then delete and run the installer again.
For not expanding the exact error while using different lanuage, it is a bug in a code, we need to have some chnages in code to push this error message for other non-default languages.
Hope this helps you.
Thank you very much @kapil , by forcing the english language to english with the -en flag I got the error message mentionned and was able to fix the problem.
Appart from the error message, an other thing that got me confused is the difference of behavior between default folder and other folder. In the default folder the installer doesn't seem to care if other files already exist (data dir, older PostgreSQL installation...), but in any other directory the installer asks for a fully empty directoy.
Anyway, everything is working fine now, thanks a lot for this.
The difference of behavior between default folder and other folder you have noticed is expected behaviour, the reason is the default location "C:\Program Files\PostgreSQL\11" as the appropriate permissions and it is secured and permission for this folder will not be changed, so basically it is a secure and as appropriate permission for this folder we allow to install the PostgreSQL on default location if it is empty or non-empty.
For non-default directoreis we are not sure what permission has been set by the user and has appropriate permissions or not and also due to insecure we doesn't allow to install the PostgreSQL on non-default location if it is non-empty. So we forcefully ask the user to remove the exiting directory and create a folder in location which is secure and has appropriate permissions.
Hope this helps you.