Can't delete package

I tried to install onlyoffice as described in this site
I skipped the postgresql part. whatever. Now I am trying to delete it but I can't. I do so from the synaptic package manager. I get this error

E: onlyoffice-documentserver: installed onlyoffice-documentserver package post-removal script

in the details it says

(Reading database ... 357115 files and directories currently installed.)
Purging configuration files for onlyoffice-documentserver (6.2.0-123) ...
psql: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
dpkg: error processing package onlyoffice-documentserver (--purge):
installed onlyoffice-documentserver package post-removal script subprocess returned error exit status 2
Errors were encountered while processing:
onlyoffice-documentserver
E: Sub-process /usr/bin/dpkg returned an error code (1)
A package failed to install. Trying to reco?
what else can I try to delete this package

I also try it with the terminal, but I get the following

Try: sudo apt --purge remove <appname> or sudo apt remove ^<appname>
Just fyi, I've never tried the second one. Instead of the second one, I usually just do either sudo nautilus or sudo thunar and then search for the appname and delete.

1 Like

I tried purge. but I kept having this problem. I tried few other tricks but nothing seemed to fully fix the issue. I did a system restore

If push comes to shove, you can use locate command to locate the files, then the "rm -rf" command to remove them- which is pretty much what Uninstalling does. It is a bit more tedious but...
Before going that route- A proper removal is preferred just for ease:
Did you Kill pid (Or use System Monitor) the processes for openOffice, then try removal?

1 Like

I don't know, I was restarting my laptop all the time. shouldn't this be enough to kill the pid?
I fixed this with timeshift, but I want to learn how to deal with such problems in the future

I mean I deleted the gpg key, everything I could. but it still was listed in the synaptic PM as (partly) installed. I remember that during installation it showed an error or warning. and even installing it again (not re-installing) in synaptic threw an error, a dependency error which couldn't be resolved by me.

That may explain the refused connection then, if pieces were missing. This error may cause an inability to remove- at least on the surface.
Running an installer (or in this case, uninstaller) checks file integrity before removing files. IF that integrity is questionable, it defaults to User Control instead of deciding what to do for you.
Aside from 'rm -rf' above, which can be dangerous, another method of removal is to Reinstall the package with dependencies (sudo apt install -y ____) to give the files integrity, then run the removal. Or "sudo apt install --reinstall ______".
Another is to use "sudo apt --fix-broken install", then remove the software.
Let's say all of the above gets borked. Then you must remove the apt-lock on the file and run the uninstaller. I do not have a saved copy in my commands cheat sheet for that and it's very late here... I may look it up if needs be or append this later... But for now, with all the options above, let's hope it does not come to that.

1 Like

someone in reddit told me that a broken package can cause this problem

Yes, very true. But the commands above should still help resolve them, like

sudo apt --fix-broken install

1 Like