inaabi / Guides / dpkg left a package half configured

dpkg left a package half configured

Read dpkg --audit, retry the configure step, and remove the package if that script still fails.

Tested on Debian 12 (bookworm), 2026-12-04.

apt or dpkg stopped in the middle. A package is unpacked and its configure script failed, so later installs refuse to go on until that package is configured or removed.

Retry the configure step first. Removing the package is the undo when the script will never succeed and you do not need the package.

Tested on Debian GNU/Linux 12 (bookworm), 2026-12-04, in a throwaway container. The package in the output, gt-broken, is one this test built so its postinst exits 1. On a server the name is whatever dpkg --audit prints.

Confirm it

A healthy database finishes this with no output and exit 0. That was the state of the container before the broken package was installed:

dpkg --configure -a
configure_rc=0

After the failed install, dpkg said:

Setting up gt-broken (1) ...
dpkg: error processing package gt-broken (--install):
 installed gt-broken package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 gt-broken

The install command exited 1.

dpkg --audit
dpkg -s gt-broken
The following packages are only half configured, probably due to problems
configuring them the first time.  The configuration should be retried using
dpkg --configure <package> or the configure menu option in dselect:
 gt-broken            postinst always fails
Package: gt-broken
Status: install ok half-configured

half-configured means the files are unpacked and the configure script did not finish. Read the line under the package name. That line is the package description here; on a real failure the lines above it are the script's own error.

Retry

dpkg --configure -a

This runs the configure scripts that are still pending. It does not skip a script that fails again. The same package failed the same way on the retry:

Setting up gt-broken (1) ...
dpkg: error processing package gt-broken (--configure):
 installed gt-broken package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 gt-broken

Exit status was 1. If the script failed because a file was missing or the disk was full, fix that and run dpkg --configure -a again. If the script fails the same way every time, the package will not become installed by repeating the command.

Remove it

When you do not need the package, remove it. This is the command that removed the half-configured test package:

dpkg --remove --force-remove-reinstreq gt-broken

Use the name from dpkg --audit, not a wildcard.

Removing gt-broken (1) ...

The command exited 0.

Verify

dpkg -s gt-broken
dpkg --configure -a
dpkg-query: package 'gt-broken' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.

dpkg -s exits 1 when the package is gone. That is the check that it is gone. dpkg --configure -a then exits 0, which means nothing is still waiting.

Undo

Undo of the remove is installing the package again, after the reason the script failed is fixed. dpkg --remove does not keep a copy of a package you built locally. A package that came from Debian is installed again with apt-get install once dpkg --configure -a exits 0.

If the retry had succeeded, the undo of a bad upgrade is the package you had before, from a backup of the deb or from the repository's older version. This test did not roll a real Debian package back. It removed a package that had never configured.

Distro notes

Tested on Debian 12 (bookworm), dpkg from that image, package hello 2.10-3 used only to show a normal install still works before the broken one. Ubuntu uses the same dpkg --audit and dpkg --configure -a. An Ubuntu run is recorded on this page only after those commands have been run there.

dnf and rpm are a different database. See [dnf-transaction-failed](dnf-transaction-failed.md).

Another apt or dpkg holding /var/lib/dpkg/lock-frontend is a different stop. Do not delete that lock file. Wait until the other command exits, or end that command if it is stuck, then retry.

Related

Questions

What does "install ok half-configured" mean?

The package files are unpacked and the configure script did not finish. On the test package, dpkg -s printed Status: install ok half-configured, and dpkg --configure -a ran the script again. The script exited 1 again, and the package stayed half-configured until it was removed.

Should I delete /var/lib/dpkg/lock-frontend?

No. That file is the lock. Another apt or dpkg is using the database, or a killed command left the database mid-update. Wait for the other command, or fix the half-configured package this page describes. Deleting the lock file does not finish the configure script.

Sources