E: dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem. means an earlier install stopped halfway, while packages were being set up. Run sudo dpkg --configure -a once; it finishes the interrupted setup, and apt-get works again.

The message names its own fix, and in the test that fix was enough: one dpkg --configure -a with exit code 0, then the install that had failed went through.

The error

apt-get install -y nano
E: dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem.
exit code: 100

Why it happens

An apt-get install -y vim was running and had reached the setup stage: the dpkg processes were running --configure --pending, and the log ended with Setting up lines. Both dpkg and apt-get were then killed with pkill -9. That left packages unpacked but not configured, and the next apt-get refused to start any new work until that was finished. The pkill lines below break the package system on purpose to reproduce the error; do not run them.

ps -o pid,cmd -C dpkg
    PID CMD
   3936 /usr/bin/dpkg --status-fd 27 --configure --pending
   3939 /usr/bin/dpkg --status-fd 27 --configure --pending
pkill -9 -x dpkg
pkill -9 -x apt-get
...
tail -3 /tmp/vim.log
Setting up libpython3.12t64:amd64 (3.12.3-1ubuntu0.17) ...
Setting up vim-common (2:9.1.0016-1ubuntu7.20) ...
Setting up vim-runtime (2:9.1.0016-1ubuntu7.20) ...

This test stopped the install with pkill -9; other ways of stopping an install before it ends were not tried. If you see the message in WSL, think back to the last install or upgrade you started and whether it printed its final lines.

The fix

dpkg --configure -a > /tmp/conf.log 2>&1
exit code: 0
tail -3 /tmp/conf.log
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vim (vim) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vimdiff (vimdiff) in auto mode
Processing triggers for libc-bin (2.39-0ubuntu8.9) ...
apt-get install -y nano > /tmp/nano.log 2>&1
exit code: 0
...
dpkg --audit
exit code: 0

dpkg --configure -a finished the setup of vim that had been cut off: the last lines of its log are vim's alternatives being registered. The nano install that had failed with exit code 100 then returned 0, and dpkg --audit printed nothing and returned 0. Run that audit after the fix if you want a quick check that no package is left half set up.

The commands ran as root in the container; in your WSL terminal use sudo dpkg --configure -a. If the configure step itself stops with an error about one package, that is a different problem from this message and was not reproduced here.

How it was reproduced

The capture was made in an ubuntu:24.04 container (Ubuntu 24.04.5 LTS, apt 2.8.3, Docker Engine 29.9.2) standing in for Ubuntu in WSL. A script started DEBIAN_FRONTEND=noninteractive apt-get install -y vim in the background, waited until a dpkg process appeared plus one second, then killed dpkg and apt-get with pkill -9 -x and ran apt-get install -y nano, which failed with the message above. dpkg --configure -a, a second nano install and dpkg --audit followed.

Frequently asked

How do I fix dpkg was interrupted in Ubuntu WSL?
Run sudo dpkg --configure -a, then repeat the install that failed. In the test the configure step returned exit code 0 and the next apt-get install returned 0.
What causes E: dpkg was interrupted?
In the test it followed killing dpkg and apt-get with pkill -9 while packages were being set up. The next apt-get install refused to run with exit code 100.
How do I check that dpkg has no half-installed packages?
Run dpkg --audit. After dpkg --configure -a it printed nothing and returned exit code 0 in the test.

More decoded errors in the Fixes category. If apt-get instead says the dpkg lock is held, see Could not get lock /var/lib/dpkg/lock-frontend.