Ubuntu – How to fix broken synaptic updates: “Package is in a very bad inconsistent state”

aptitudeUbuntu

I have a Dell Mini9 running Ubuntu 8.10. One day I had the bright idea to see if I could install a LAMP stack. I had trouble installing MySQL 5.0. I don't recall the error, but ever since all attempts to run update-manager, synaptic, or apt-get fails with an error about mysql-server-5.0: "Package is in a very bad inconsistent state".

I've tried apt-get remove mysql-server-5.0 and also install but with no luck. Both fail with the same error below. How can I fix this?

$ sudo apt-get remove mysql-server-5.0
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  dhcdbd libisc32
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  mysql-server-5.0
0 upgraded, 0 newly installed, 1 to remove and 164 not upgraded.
1 not fully installed or removed.
After this operation, 85.4MB disk space will be freed.
Do you want to continue [Y/n]? 
dpkg: error processing mysql-server-5.0 (--remove):
 Package is in a very bad inconsistent state - you should
 reinstall it before attempting a removal.
Errors were encountered while processing:
 mysql-server-5.0
E: Sub-process /usr/bin/dpkg returned an error code (1)

Best Answer

None of the other answers worked for me on Maverick.

In my case, I found this worked:

sudo rm /var/lib/dpkg/info/flashplugin-nonfree.prerm

sudo dpkg --remove --force-remove-reinstreq flashplugin-nonfree

(replacing "flashplugin-nonfree" with the name of the broken package, and replacing "prerm" with the type of script that failed - in my case it was "postrm", the post-removal script.)

And they say Ubuntu is easy to use!! grumble grumble

Related Question