i have a machine where a user deleted their postgresql folder from the command line in an attempt to uninstall postgres. now when we try to install any other packages - even unrelated ones - we keep getting error messages about postgresql-common.
I tried to uninstall everything related to postgresql-9.3 and postgresql-9.4 manually via the command line but that's not working.
This is what happens when I try:
jj@testdev:~/Documents/svc_core_design/svc_core_git/svc-core-docs/net-svc$ sudo apt-get purge postgresql-client-9.3
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'postgresql-client-9.3' is not installed, so not removed
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
postgresql-9.3 : Depends: postgresql-client-9.3 but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
jj@testdev:~/Documents/svc_core_design/svc_core_git/svc-core-docs/net-svc$
To see what postgresql components he still has I ran the following command:
sudo dpkg --get-selections | grep -v deinstall
postgresql-9.3 purge
postgresql-client-9.4 install
postgresql-client-common install
postgresql-common install
I would like to either remove all postgresql related items if possible, or re-install so it's working properly.(don't need both versions if we re-install. Just 9.4 would be fine.) Can you tell me how I can do that via command line?
EDIT 1
Here are the results from trying to run "sudo apt-get -f install" without any package name:
jj@testdev:/var/lib/postgresql$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libjs-underscore linux-image-3.16.0-25-generic linux-image-3.16.0-33-generic linux-image-extra-3.16.0-25-generic linux-image-extra-3.16.0-33-generic
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 8 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up postgresql-common (166.pgdg14.10+1) ...
insserv: warning: script 'mongod' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `mongod'
insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `mongod'
* Starting PostgreSQL 9.3 database server * Error: /var/lib/postgresql/9.3/main is not accessible or does not exist
[fail]
* Starting PostgreSQL 9.4 database server * Error: /var/lib/postgresql/9.4/main is not accessible or does not exist
[fail]
invoke-rc.d: initscript postgresql, action "start" failed.
dpkg: error processing package postgresql-common (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
postgresql-common
E: Sub-process /usr/bin/dpkg returned an error code (1)
jj@testdev:/var/lib/postgresql$ sudo
I've also made sure that the owner on the /var/lib/postgresql folder is postgres, in case that helps. Perhaps I should manually create the folder structure it's complaining about?
/var/lib/postgresql/9.3/main
Any other suggestions?
EDIT 2
I installed aptitude and tried to purge postgresql 9.3 and 9.4 It fails with:
jj@testdev:/var/lib/postgresql$ sudo aptitude purge postgresql-9.3
The following packages will be REMOVED:
postgresql-9.3{p}
The following partially installed packages will be configured:
postgresql-common
0 packages upgraded, 0 newly installed, 1 to remove and 5 not upgraded.
Need to get 0 B of archives. After unpacking 17.6 MB will be freed.
Do you want to continue? [Y/n/?] Y
(Reading database ... 339475 files and directories currently installed.)
Removing postgresql-9.3 (9.3.5-2.pgdg14.10+1) ...
* Stopping PostgreSQL 9.3 database server * Error: /var/lib/postgresql/9.3/main is not accessible or does not exist
[fail]
invoke-rc.d: initscript postgresql, action "stop" failed.
dpkg: error processing package postgresql-9.3 (--purge):
subprocess installed pre-removal script returned error exit status 1
Errors were encountered while processing:
postgresql-9.3
E: Sub-process /usr/bin/dpkg returned an error code (1)
Failed to perform requested operation on package. Trying to recover:
Setting up postgresql-common (166.pgdg14.10+1) ...
* Starting PostgreSQL 9.3 database server * Error: /var/lib/postgresql/9.3/main is not accessible or does not exist
[fail]
* Starting PostgreSQL 9.4 database server * Error: /var/lib/postgresql/9.4/main is not accessible or does not exist
[fail]
invoke-rc.d: initscript postgresql, action "start" failed.
dpkg: error processing package postgresql-common (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
postgresql-common
jj@testdev:/var/lib/postgresql$
EDIT 3:
Here are the results of running the command "sudo apt-get purge postgresql-client-9.4 postgresql-client-common postgresql-common"
Removing postgresql-common (166.pgdg14.10+1) ...
* Stopping PostgreSQL 9.3 database server * Error: /var/lib/postgresql/9.3/main is not accessible or does not exist
[fail]
* Stopping PostgreSQL 9.4 database server * Error: /var/lib/postgresql/9.4/main is not accessible or does not exist
[fail]
invoke-rc.d: initscript postgresql, action "stop" failed.
dpkg: error processing package postgresql-common (--purge):
subprocess installed pre-removal script returned error exit status 1
* Starting PostgreSQL 9.3 database server * Error: /var/lib/postgresql/9.3/main is not accessible or does not exist
[fail]
* Starting PostgreSQL 9.4 database server * Error: /var/lib/postgresql/9.4/main is not accessible or does not exist
[fail]
invoke-rc.d: initscript postgresql, action "start" failed.
dpkg: error while cleaning up:
subprocess installed post-installation script returned error exit status 1
and when I check what's installed:
jj@testdev:/var/lib/postgresql$ sudo dpkg --get-selections | grep -v deinstall | grep post
libreoffice-sdbc-postgresql install
postgresql-9.3 purge
postgresql-9.4 purge
postgresql-common purge
printer-driver-postscript-hp install
jj@testdev:/var/lib/postgresql$
sudo apt-get -f install
?sudo apt-get install -f
apt-get install aptitude
then runaptitude purge [package name(s)]
. Aptitude just tries harder than apt-get to complete the requested operation.