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?

2

6 Answers 6

84

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

sudo apt-get install --reinstall packagename 
7
  • 1
    Yes, but a warning that after reinstalling packagename, apt-get will then proceed to configure any half-configured packages. Oct 23, 2015 at 13:53
  • 5
    this is safer than the accepted answer imho.
    – Zanna
    Jun 25, 2017 at 14:44
  • sudo apt-get install --reinstal ncurses-base and later I ran the sudo apt-get update using the root user (sudo -s), it worked just like that... Jun 13, 2018 at 2:36
  • great. only that solution solved my problem
    – iWizard
    Jul 4, 2018 at 13:33
  • this did it for me. php-pear was giving me an headache. thanks!
    – pcarvalho
    May 25, 2019 at 22:27
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.

3
  • 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 packages.ubuntu.com and ran sudo dpkg -i WHERE/THE/DOWNLOADED/PACKAGE/IS. Then it became all good. Mar 15, 2015 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, 2015 at 12:13
  • Without --dry-run, as you said, it worked for me. Thank you!
    – forvas
    Jan 24, 2018 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.

2
  • 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, 2021 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, 2022 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.

2
  • synaptic does not list the package in broken category :(
    – Barun
    Jul 2, 2014 at 8:00
  • @Barun This answer contains a screenshot showing how to show and fix broken packages in Synaptic.
    – karel
    Apr 16, 2022 at 23:49
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

8
  • 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 Sep 12, 2016 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, 2016 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. Sep 13, 2016 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, 2016 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. Sep 13, 2016 at 23:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .