0

I was installing PostgreSQL 9.4 and pgAdmin on my Ubuntu 12.04 and after that I needed to install Postgis extension for Postgres as well. Before the Postgis step all was fine. There I tried with compiling the source code as well as with dpkg -i .deb method to install and both gave an error about a file missing - libpq-fe.h. I found out it's in a libpq-dev package, so did sudo apt-get install libpq-dev. This returned me that this package is already installed. Though a folder in which the file libpq-fe.h (and others) should be was empty. So my guess was to remove libpq-dev and install it again. I tried both with sudo apt-get remove ... and sudo apt-get remove --purge ....

From here the package manager broke and right now any attempt to install a package (below Wine, just for example) or do a sudo apt-get upgrade returns:

adambo@adam-pc:~/Downloads/postgis-2.2.2$ sudo apt-get install wine
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 libpq-dev : Depends: libpq5 (= 9.1.20-0ubuntu0.12.04) but 9.5.3-1.pgdg12.4+1 is to be installed
 postgresql-server-dev-9.4 : Depends: libpq-dev (>= 9.4~) but 9.1.20-0ubuntu0.12.04 is to be installed
 wine : Depends: wine1.4 but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

What I've tried:

  • sudo apt-get update
  • sudo apt-get upgrade
  • sudo apt-get clean
  • sudo apt-get remove
  • sudo apt-get autoremove
  • sudo apt-get install -f

Some returned regular results (or nothing), but some returned same as in code above.

I also tried to remove libpq-dev and libpq5 packages, but any attempt resulted in the code above again.

But sudo apt-get install -f gives me:

adambo@adam-pc:~/Downloads/postgis-2.2.2$ sudo apt-get install -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following extra packages will be installed:
  libpq-dev
Suggested packages:
  postgresql-doc-9.5
The following packages will be upgraded:
  libpq-dev
1 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
1 not fully installed or removed.
Need to get 0 B/228 kB of archives.
After this operation, 141 kB disk space will be freed.
Do you want to continue  [Y/n]? Y
dpkg: dependency problems prevent configuration of libpq-dev:
 libpq-dev depends on libpq5 (= 9.1.20-0ubuntu0.12.04); however:
  Version of libpq5 on system is 9.5.3-1.pgdg12.4+1.
dpkg: error processing libpq-dev (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                                              Errors were encountered while processing:
 libpq-dev
E: Sub-process /usr/bin/dpkg returned an error code (1)


What could I do to at least restore apt-get functionality?

  • Could you try sudo apt-get remove libpq-dev libpq5 postgresql-server-dev-9.4 and then sudo apt-get -f install. – fosslinux Jul 26 '16 at 20:39
  • first command returned same E: Unmet dependencies but longer since there were more packages. The sudo apt-get -f install returned very same as above. Seems like my apt-get remove is kind of locked. – adamczi Jul 26 '16 at 20:42
  • Hmm. Have you added a PPA recently? – fosslinux Jul 26 '16 at 23:33
  • I added the PPA from Postgres site only, should be rather safe. I think removing the libpq-dev package and installing it again could help, since the package is broken anyway (files not where they should be). The problem is the apt-get remove won't work – adamczi Jul 27 '16 at 5:20
  • Please try sudo dpkg --remove --force-remove-reinstreq libpq-dev libpq5 postgresql-server-dev-9.4 – fosslinux Jul 27 '16 at 5:26
0

After tries and fails I tried with Aptitude (fortunately installed already) and pressed g to install/remove/repair packages. There I followed what it proposed to remove and... Error disappeared. libpq-dev was removed. Though some of other packages I actually need were removed as well.

Therefore I recommend it to people who are able to easily restore and reinstall missing packages.

0

When discovering that files from libpq-dev are missing, the command to run is:

sudo apt-get install --reinstall libpq-dev

This command leaves alone the dependent packages, contrary to apt-get remove which dragged you into a dependency mess.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

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