The "short read in buffer_copy" error indicates a corrupted .deb file that dpkg cannot extract. This typically happens due to incomplete downloads, hardware failures, or corrupted package mirrors. Clear your apt cache and re-download the package to resolve the issue.
This error occurs when dpkg tries to extract files from a .deb package but encounters corrupted or truncated data. The decompression layer discovers unexpected data, causing the extraction process to end prematurely. Dpkg reports that it did not receive all the data that was announced in the package header—hence the "short read" error. This is essentially dpkg's way of indicating the .deb file itself is damaged or incomplete, rather than an issue with the installation process itself.
Remove all cached .deb files and fetch fresh copies:
sudo apt clean
sudo apt updateThe apt clean command removes all cached package files in /var/cache/apt/archives/, ensuring you get fresh downloads of any corrupted packages.
Try installing the package again, or use the fix-broken flag:
sudo apt install -fThis will attempt to fix any broken dependencies and re-download packages. If you were installing a specific package:
sudo apt install <package-name>If the error persists, the mirror server itself may be distributing a corrupted package. Change your apt mirror:
1. Edit /etc/apt/sources.list or relevant .list files in /etc/apt/sources.list.d/
2. Replace the current mirror URL with an alternative one
3. Run sudo apt update again
For Ubuntu users, you can use the mirror selection tool:
sudo software-properties-gtkThen select a different mirror from the dropdown.
If the error continues across multiple packages, check your storage device:
dmesg | tail -20Look for hardware errors. If you suspect disk corruption, run a filesystem check (requires root and ideally a non-root partition):
sudo fsck.ext4 -n /dev/sdX # -n flag does a read-only checkIf errors are found, run without -n to fix them (requires unmounting the partition first).
Insufficient disk space can cause failed writes and file corruption:
df -hEnsure you have at least 100-200 MB free space in /var. If disk space is low, delete unnecessary files or uninstall unneeded packages.
Some antivirus software (like ESET NOD32) can interfere with package integrity checking. If you have antivirus running:
1. Temporarily disable real-time scanning
2. Attempt the package installation again
3. Re-enable the antivirus after completion
If this resolves the issue, configure your antivirus to exclude /var/cache/apt/ and /var/lib/apt/ from scanning.
This error has been documented since the early dpkg versions (bug #158999 in 2002) and remains common. The error message itself is somewhat misleading—it's actually coming from zlib decompression rather than a true buffer read operation. On systems with filesystems supporting delayed allocation (ext4, xfs, btrfs), sudden power failures during package installation can cause this error. If you frequently encounter this error, it may indicate underlying hardware problems. Monitor dmesg and system logs for correlating hardware errors, especially if multiple packages fail. For CI/CD environments, implement retry logic with cache clearing between attempts, and ensure mirrors are health-checked before directing traffic to them.
dpkg: serious warning: files list file for package 'package-name' contains empty filename
How to fix "files list file contains empty filename" in APT
E: Sub-process /usr/bin/dpkg returned an error code (2)
How to fix "Sub-process /usr/bin/dpkg returned an error code (2)" in APT
dpkg-divert: error: rename involves overwriting 'path' with different file
How to fix dpkg-divert rename conflicts in APT
E: Sub-process /usr/bin/dpkg returned an error code (1) during kernel installation
How to fix "dpkg returned an error code (1)" in APT kernel installation
dpkg: dependency problems prevent configuration of triggers
dpkg: dependency problems prevent configuration of triggers in apt