APT – How to Fix Half-Installed Package

aptdpkgpackage-management

I am getting error while using sudo apt-get upgrade stating:

dpkg: error processing libgfortran3:amd64 (--configure):
  package libgfortran3:amd64 is not ready for configuration
  cannot configure (current status `half-installed')
Errors were encountered while processing:
  libgfortran3:amd64
E: Sub-process /usr/bin/dpkg returned an error code (1)

It does not seem to block the installation/upgrade other applications.
I believe this problem arose due to direct shutting down of my PC while the application was being upgraded.

How can I fix this?

Best Answer

sudo dpkg --remove --force-remove-reinstreq --dry-run libgfortran3:amd64

That's just a dry-run. I'm not sure what removing libgfortran3 will take with it but run that and see. Assuming it's not going to gobble the whole system, run it again without the --dry-run and then you can sudo apt-get install ... the packages you need back.

Related Question