55

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?

Radu Rădeanu
  • 169,590
Barun
  • 725
  • 1
  • 6
  • 10

6 Answers6

84

For the half installed package error, --reinstall worked for me:

sudo apt-get install --reinstall packagename 
muru
  • 197,895
  • 55
  • 485
  • 740
49
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.

Oli
  • 293,335
  • 4
    Worked out, thanks! For the record, I ran it and it said dpkg: warning: package is in a very bad inconsistent state; you should reinstall it before attempting a removal so I downloaded the package manually from http://packages.ubuntu.com/ and ran sudo dpkg -i WHERE/THE/DOWNLOADED/PACKAGE/IS. Then it became all good. – Bora M. Alper Mar 15 '15 at 11:51
  • 1
    In my case, after following these instructions, just running 'apt-get install -f' reinstalled the package and also fixed several others with broken dependencies because of it. This was for the libx11-data package on debian 7. – bchurchill Apr 28 '15 at 12:13
  • Without --dry-run, as you said, it worked for me. Thank you! – forvas Jan 24 '18 at 17:47
8
sudo apt install --reinstall packagename

This works like charm. It resolved an issue that I had been experiencing for months. My case was with the package libmysqlcppconn7v5

All I did was run sudo apt install --reinstall libmysqlcppconn7v5

6

I got a same "half-installed package" problem with a package kibana. I got the following error:

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

If anyone is still facing this kind of problem, then you can try this:

sudo rm /var/lib/dpkg/info/kibana*
cd /var/cache/apt/archives
sudo rm kibana*
apt-get --reinstall install kibana

This works for me. You just need to replace the word 'kibana' with your half-installed package name.

edwinksl
  • 23,789
  • This just removes the pkg from dpkg. It doesnt remove any artifacts that were actually unpacked and moved to /usr/bin or wherever. You could end up w/1.5 actual installs, depending on where it originally broke. Although, from there checking the source pkg/debian directory, there should be a makefile or similar, which would give the locations of any stragglers. – Nate T Sep 19 '21 at 17:42
  • If this answer doesn't work you may also need to run rm /var/lib/dpkg/triggers/packagename. Replace the word 'packagename' with your half-installed package. – karel Apr 16 '22 at 23:51
3

If you want to fix this through GUI, you can use synaptic. Synaptic is an excellent package management tool that used to be included in older versions of ubuntu. To install it:

sudo apt-get install synaptic

click on fix broken packages.

Mijo
  • 293
3

This should fix your problem without re-installing the package.

sudo dpkg --force-remove-reinstreq --remove <package_name here>

Followed by: sudo apt-get update

edwinksl
  • 23,789
c0degeas
  • 141
  • Why --force-remove-reinstreq? The package manager doesn't state that a re-installation is required. Generally, a regular removal works just fine for unconfigured packages. -1 – David Foerster Sep 12 '16 at 20:21
  • It's just what I do when sudo apt-get remove <package is out of option and I don't want to re-install that half-installed package .Then, I use --force-remove-reinstreq to remove those junks..

    PS : It's on Linux Mint.. I doubt if it'll be any different as Linux is based on Ubuntu..

    – c0degeas Sep 13 '16 at 21:44
  • 1
    The package manager works the same in all Debian-based distributions (that's what dpkg stands for after all), but you shouldn't use --force-* "just in case". The error messages are there for a reason and shouldn't be taken lightly by inexperienced users, which is why you shouldn't suggest unnecessary --force-* options to them. Otherwise we could just recommend to always use --force-all or, better yet, remove the --force-* options from dpkg altogether and have them be the default behaviour because that would be easier and more convenient. – David Foerster Sep 13 '16 at 22:28
  • Okay, Admit it... I was being more concerned about getting the job done than, knowing what and how exactly it is done.. Apologies.. – c0degeas Sep 13 '16 at 23:31
  • Hm… I'm just seeing that the accepted answer suggests the same. So I might be wrong about --force-remove-reinstreq being unnecessary. But that also means that your answer is (almost) a duplicate of it. Better luck next time. – David Foerster Sep 13 '16 at 23:47
  • @DavidFoerster haha... You guys treat re("Stack[.]*") like it's some kind of game.. :D – c0degeas Sep 14 '16 at 12:23
  • If you mean that both games and SE have rules of engagement, then I agree with you. – David Foerster Sep 14 '16 at 13:57
  • @DavidFoester The --force-remove-reinstreq flag doesn't try to reinstall. The reinstallrequest is a flag tacked onto half configured packages, which is why they wont uninstall in the first place. – Nate T Sep 19 '21 at 17:50