dpkg cannot unpack a .deb and reports error processing archive
Your error
dpkg: error processing archive /var/cache/apt/archives/foo_2.0-1_amd64.deb (--unpack):3 more lines it can showFix it fast
Most common cause, 1 of 4Another installed package already owns the file
If the owning package is a leftover you no longer need (often the one from the outside repository), remove it, then let apt finish the interrupted install.
sudo apt remove foo-data
sudo apt --fix-broken installShort answer
dpkg prints error processing archive (--unpack) when it cannot unpack a .deb, and the indented line under it gives the reason. On Ubuntu 24.04 with dpkg 1.22, look for trying to overwrite (a file another package owns), unexpected end of file or stream (a download cut short) or No space left on device (a full disk).
Which cause do you have?
Run the failing install once more and keep only the dpkg line that names the archive plus the indented line right below it; check free space at the same time. trying to overwrite, unexpected end of file or stream and No space left on device each lead to a different cause.
sudo apt install foo 2>&1 | grep -A1 "error processing archive"
df -h / /varThen find the line you see in this list and open its fix:
- 1Another installed package already owns the file
trying to overwrite '<path>', which is also in package <other> (<version>) - 2Both packages have to stay and the overlap is a packaging bug
The same trying to overwrite line, but removing the owner would also remove software you need - 3The downloaded .deb in the apt cache is cut short
cannot copy extracted data for '<file>' to '<file>.dpkg-new': unexpected end of file or stream - 4The disk filled up during the unpack
cannot copy extracted data for '<file>' to '<file>.dpkg-new': cannot write (No space left on device)
What does the error look like?
dpkg: error processing archive /var/cache/apt/archives/foo_2.0-1_amd64.deb (--unpack):trying to overwrite '/usr/share/foo/data.xml', which is also in package foo-data (1.0-1)cannot copy extracted data for './usr/lib/foo/libfoo.so' to '/usr/lib/foo/libfoo.so.dpkg-new': unexpected end of file or streamErrors were encountered while processing:
Cause 1 of 4
Another installed package already owns the file
You seetrying to overwrite '<path>', which is also in package <other> (<version>)
Check
error processing archive with trying to overwrite means the new package ships a file that dpkg already records as belonging to another package. Debian policy calls that an error unless the new package declares that it Replaces the old one; packages from different publishers, such as a PPA, a vendor repository or a .deb installed by hand, do not know about each other's files. Find the owner and where it came from.
dpkg -S /usr/share/foo/data.xml
apt-cache policy foo-dataFix
If the owning package is a leftover you no longer need (often the one from the outside repository), remove it, then let apt finish the interrupted install.
sudo apt remove foo-data
sudo apt --fix-broken installVerify
dpkg -S now names the new package as the owner of the file, and apt reports nothing left to fix.
dpkg -S /usr/share/foo/data.xmlConfirmed by debian.org
Cause 2 of 4
Both packages have to stay and the overlap is a packaging bug
You seeThe same trying to overwrite line, but removing the owner would also remove software you need
Check
error processing archive for a file shared by two packages you must keep means the newer package lacks the Replaces field it should have, which is a bug for its maintainer. dpkg can take the file over once with the overwrite force option; its manual warns that force options are meant for experts and can break the system when used without understanding.
Fix
Unpack only the one archive with --force-overwrite, let apt complete the rest, and report the overlap to whoever publishes the newer package.
sudo dpkg -i --force-overwrite /var/cache/apt/archives/foo_2.0-1_amd64.deb
sudo apt --fix-broken installVerify
dpkg --audit prints nothing, so no package is left half installed.
sudo dpkg --auditConfirmed by manpages.ubuntu.com
Cause 3 of 4
The downloaded .deb in the apt cache is cut short
You seecannot copy extracted data for '<file>' to '<file>.dpkg-new': unexpected end of file or stream
Check
error processing archive with unexpected end of file or stream means dpkg ran out of data before the end of a file inside the .deb, so the copy in /var/cache/apt/archives is incomplete. dpkg's own copy routine raises exactly that message when the archive stream ends before the expected size.
ls -l /var/cache/apt/archives/foo_2.0-1_amd64.debFix
Clear the cached package files so apt fetches a fresh copy, then install again.
sudo apt clean
sudo apt --fix-broken installVerify
apt downloads the package again and the unpack step completes.
sudo dpkg --auditConfirmed by salsa.debian.org
Cause 4 of 4
The disk filled up during the unpack
You seecannot copy extracted data for '<file>' to '<file>.dpkg-new': cannot write (No space left on device)
Check
error processing archive with No space left on device means dpkg could not write the extracted file because the file system holding it is full. df shows which mount is at 100 percent; /, /usr and /var are the ones that matter for packages.
df -h / /usr /var /bootFix
Free space first. Removing cached .deb files and packages that were only pulled in as dependencies and are no longer needed are the two apt-side steps; then retry the install.
sudo apt clean
sudo apt autoremove
sudo apt --fix-broken installVerify
df shows free space on the mount, and apt finishes without an unpack error.
df -h / /varConfirmed by manpages.ubuntu.com
How do I stop it coming back?
- Before installing a vendor .deb, run dpkg -c on it and dpkg -S on a few of its paths to see whether an installed package owns them already.
- Alert on disk use for / and /var on servers that take unattended upgrades, long before either one fills.
- Remove PPAs and hand-installed .deb files once the Ubuntu archive carries the same software.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.