Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

(Note: This question has been compeltely rewritten from its original form, so it reflects the actual problem and will help others find a solution to the same issue).


I still haven't been able to successfully install PostgreSQL on my Windows 7 Ultimate x64 computer. See this prior question for some history.

I did a fresh instillation of 9.2 and the only error I got was this one:

error installing

It reads:

"Problem running post-install step. Installation may not complete correctly. The database cluster initialisation failed".

This occurs even after I do a complete manual uninstall of PostgreSQL and pgAmdin-III:

  • Ran the PostgreSQL uninstaller, which failed with the error Error stopping service postgresql-x64-9.2.
  • Removed all the PostgreSQL-related registry entries for PostgreSQL under HKEY_LOCAL_MACHINE\SOFTWARE and HKEY_CURRENT_USER\SOFTWARE
  • Removed the postgres user account using net user postgres /delete in an Administrator command prompt (shift-right clicked on "Command Prompt" in start menu, chose "Run as administrator")
  • Removed the postgres user profile
  • Deleted the C:\Program Files\PostgreSQL\ directory, including the data directory within %appdata%
  • Removed some PgAdmin-III registry entries that pointed to PostgreSQL
  • Removed the service account for postgres from services.msc

When I reboot and try the installer again it fails with the same message.

The install-postgresql.log file from %TEMP% contains:

Executing cscript //NoLogo "C:\Program Files\PostgreSQL\9.2/installer/server/initcluster.vbs" "NT AUTHORITY\NetworkService" "postgres" "****" "C:\Program Files\PostgreSQL\9.2" "C:\Program Files\PostgreSQL\9.2\data" 5432 "DEFAULT"
Script exit code: 1

then another error a bit later:

creating template1 database in C:/Program Files/PostgreSQL/9.2/data/base/1 ... initdb: could not execute command ""C:/Program Files/PostgreSQL/9.2/bin/postgres.exe" --boot -x1 -F ": No error

See full installer log file download here.

share|improve this question
2  
It really should be as simple as "Install, run". It looks like you've tried so many different weird things that it's hard to say what state your machine is in now. As I commented in your last post, if you don't have any databases of value on the machine I'd just totally uninstall all PostgreSQL versions, delete the user account, and install normally without attempting to manually initdb or any of that. You're doing some weird things, like trying to follow the pg_upgrade guide for what appears to be a fresh install. –  Craig Ringer Nov 17 '12 at 6:36
    
@CraigRinger can you walk me through the process of a clean uninstall? I used the uninstaller and deleted the folders from program files. I can't find any postgres account in the control panel, maybe the uninstaller deleted it? –  Celeritas Nov 17 '12 at 12:43
    
    
@CraigRinger I tried net user postgres /delete but I get "System error 5. Access is denied" –  Celeritas Nov 18 '12 at 12:01
    
Did you run the command prompt as Administrator? Remember, under UAC, even if you have local admin access you have to explicitly run programs with admin rights. Shift-right-click on "Command Prompt" in the Start menu and choose "Run as administrator...". –  Craig Ringer Nov 18 '12 at 12:05
show 12 more comments

1 Answer

up vote 3 down vote accepted

It appears that the root cause of this issue may have been that @Celeritas's computer had an incorrect value for the COMSPEC environment variable. It had a trailing semicolon, so instead of the normal:

C:\Windows\system32\cmd.exe

it was:

C:\Windows\system32\cmd.exe;

This one-character difference is enough. The above isn't a valid command prompt path, so popen() calls were failing. Unfortunately, instead of something useful like:

'"C:\Windows\system32\cmd.exe;"' is not recognized as an internal or external command, operable program or batch file

it instead reports the delightfully useful error No error:

initdb: could not execute command ""C:/Program Files/PostgreSQL/9.2/bin/postgres.exe" --boot -x1 -F ": No error

See related:

I've reported this to the installer team and written a wiki entry to describe it. See blog post.

The issue was eventually resolved by:

  • Editing the COMSPEC environment variable
  • Uninstalling PostgreSQL
  • Rebooting
  • Reinstalling PostgreSQL

though there was a lot more before that which shouldn't actually be necessary to resolve this, including doing a total manual clean uninstall of PostgreSQL by hand.

Now I just want to find the people who wrote the program that modified this environment variable.

share|improve this answer
    
Ugh, this is tough. So much pain because of a semicolon... I'm glad to see this solved. –  dezso Nov 19 '12 at 6:32
    
@dezso It was certainly "interesting". Now I just want to know what installer did this insane thing. So far the only report I can find refers to the Sybase client driver installer (nichesoftware.co.nz/blog/2012-07/590/comspec-corruption-solved) but it doesn't mention versions etc. –  Craig Ringer Nov 19 '12 at 6:37
    
@Bevan I'd be really interested in knowing which version of the Sybase installer you found that %COMSPEC% issue with, and whether uninstalling it left a %COMSPEC% env var with nothing but a trailing semicolon. I'm wondering if it's the cause of the issue this comment is on. –  Craig Ringer Nov 19 '12 at 6:41
    
Now this is one hard problem to debug, thanks. I would never have thought about something like that. But why does the installer start the exe programs through cmd.exe and not directly? –  a_horse_with_no_name Nov 19 '12 at 8:19
    
@a_horse_with_no_name The installer actually invokes initdb via cscript.exe, running a Visual Basic script. Don't ask me why VB, I didn't write it and have no control over it. initdb then launches postgres.exe to initialize the template databases using a popen call. popen invokes a command using the shell. So the installer isn't using the shell directly. –  Craig Ringer Nov 19 '12 at 9:32
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.