Ubuntu: Error when trying to fix “unmet dependencies” on Ubuntu Server 14.04



Question:

I am trying to install php5-dev:

sudo apt-get install php5-dev  

But I got this error:

You might want to run 'apt-get -f install' to correct these:  The following packages have unmet dependencies:   postgresql-contrib-9.3 : Depends: postgresql-9.3 (= 9.3.9-0ubuntu0.14.04) but 9.3.5-0ubuntu0.14.04.1 is to be installed  E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).  

So I run the command:

sudo apt-get -f install  

But then I get this error:

invoke-rc.d: initscript postgresql, action "stop" failed.  dpkg: warning: subprocess old pre-removal script returned error exit status 1  dpkg: trying script from the new package instead ...   * Stopping PostgreSQL 9.3 database server   * Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 255.  Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 264.  (does not shutdown gracefully, now stopping immediately)    [fail]  invoke-rc.d: initscript postgresql, action "stop" failed.  dpkg: error processing archive /var/cache/apt/archives/postgresql-9.3_9.3.9-0ubuntu0.14.04_amd64.deb (--unpack):   subprocess new pre-removal script returned error exit status 1  Errors were encountered while processing:   /var/cache/apt/archives/postgresql-9.3_9.3.9-0ubuntu0.14.04_amd64.deb  E: Sub-process /usr/bin/dpkg returned an error code (1)  

My config:

Distributor ID: Ubuntu  Description:    Ubuntu 14.04.1 LTS  Release:        14.04  Codename:       trusty  

I have no idea how to fix this... Can anyone help me out?


Solution:1

It fails to stop, so try to stop it manually:

sudo service postgresql stop  

Make sure that apt cache is up to date:

sudo apt-get update  

Try again to fix:

sudo apt-get -f install  

If it doesn't work, wipe postgresql completely. See, what postgresql packages are installed:

dpkg -l | grep postgresql  

Then, remove with sudo apt-get remove <package name>. Pay attention to the messages like "THE FOLLOWING PACKAGES WILL BE REMOVED", don't accept if important stuff is listed there.

Try once more to fix:

sudo apt-get -f install  

...


Solution:2

The current version of postgresql-9.3 in trusty main is 9.3.7-0ubuntu0.14.04. To install 9.3.9-0ubuntu0.14.04 you need trusty-updates main.

Open the file /etc/apt/sources.list

sudo nano /etc/apt/sources.list  

and check if you have enabled the trusty-updates repository at least for main

eg:

deb http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe  

Results from the Ubuntu packages search

Paket postgresql-9.3        trusty (14.04LTS) (database): object-relational SQL database, version 9.3 server      9.3.7-0ubuntu0.14.04 [security]: amd64 i386      trusty-updates (database): object-relational SQL database, version 9.3 server      9.3.9-0ubuntu0.14.04: amd64 i386  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »