Ubuntu – Cannot upgrade PostgreSQL on Ubuntu

aptpostgresqlUbuntu

When I run apt-get upgrade, I get the following error :

dpkg: dependency problems prevent configuration of postgresql-9.1:
 postgresql-client-9.1 (9.1.7-0ubuntu12.04) breaks postgresql-9.1 (<< 9.1.7-0ubuntu12.04) and is installed.
  Version of postgresql-9.1 to be configured is 9.1.6-1~precise2.
dpkg: error processing postgresql-9.1 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of postgresql:
 postgresql depends on postgresql-9.1; however:
  Package postgresql-9.1 is not configured yet.
dpkg: error processing postgresql (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          No apport report written because the error message indicates its a followup error from a previous failure.
                               No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                                                         No apport report written because MaxReports is reached already
                  dpkg: dependency problems prevent configuration of postgresql-contrib-9.1:
 postgresql-contrib-9.1 depends on postgresql-9.1 (= 9.1.7-0ubuntu12.04); however:
  Version of postgresql-9.1 on system is 9.1.6-1~precise2.
dpkg: error processing postgresql-contrib-9.1 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of postgresql-contrib:
 postgresql-contrib depends on postgresql-contrib-9.1; however:
  Package postgresql-contrib-9.1 is not configured yet.
dpkg: error processing postgresql-contrib (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 postgresql-9.1
 postgresql
 postgresql-contrib-9.1
 postgresql-contrib
E: Sub-process /usr/bin/dpkg returned an error code (1)

I tried apt-get -f upgrade but the same error occurs.

What can I do to fix this issue? It totally messes up APT.

Note: I'm using the following PPA for PostgreSQL : https://launchpad.net/~pitti/+archive/postgresql

Update: Sorry for the formatting, here is a gist https://gist.github.com/e0752bb50e63ef4b3a4c

Best Answer

I had the same problem. apt-get -f install doesn't worked. With aptitude it worked.

aptitude -f install removed postgres but not the databases. Afterwards apt-get install postgres reinstalled postgres. Happy again :-)