Blog → Post


(TIP) (How to Fix) 'lzma error: compressed data is corrupt'
by @admin, april 18, 2019, 12:10am utc

When packages are installed through apt they are brought in as archive files (usually .deb files) by default and (most often) stored in the /var/cache/apt/archives folder. .deb files are archives, not unlike .zip files. Once on your system they are unpacked and installed by the install process.

If these archive files become corrupt -- for example, by a network disconnect as they are being brought down -- you can end up with the files with the archive not being able to be extracted and installed.


Here is an occurrence of that and the messages you'll see, using an issue we encountered with the libqt5webkit5 archive. This is followed by the fix.

$ sudo apt install -f Reading package lists... Done Building dependency tree Reading state information... Done Correcting dependencies... Done The following additional packages will be installed: libqt5webkit5 The following NEW packages will be installed: libqt5webkit5 0 upgraded, 1 newly installed, 0 to remove and 29 not upgraded. 5 not fully installed or removed. Need to get 0 B/9,176 kB of archives. After this operation, 39.0 MB of additional disk space will be used. Do you want to continue? [Y/n] Y (Reading database ... 161779 files and directories currently installed.) Preparing to unpack .../libqt5webkit5_5.7.1+dfsg-1_amd64.deb ... Unpacking libqt5webkit5:amd64 (5.7.1+dfsg-1) ... dpkg-deb (subprocess): decompressing archive member: lzma error: compressed data is corrupt dpkg-deb: error: subprocess returned error exit status 2 dpkg: error processing archive /var/cache/apt/archives/libqt5webkit5_5.7.1+dfsg-1_amd64.deb (--unpack): cannot copy extracted data for './usr/lib/x86_64-linux-gnu/libQt5WebKit.so.5.7.1' to '/usr/lib/x86_64-linux-gnu/libQt5WebKit.so.5.7.1.dpkg-new': unexpected end of file or stream Errors were encountered while processing: /var/cache/apt/archives/libqt5webkit5_5.7.1+dfsg-1_amd64.deb E: Sub-process /usr/bin/dpkg returned an error code (1)


You can first try install with the -f (fix) parm to attempt a fix.

$ sudo apt install -f

If that doesn't work, this will.
Remove the corrupt file from the archive cache.
The subsequent upgrade will determine the removed .deb file is needed for other things and then bring it down again fresh.

cd /var/cache/apt/archives $ sudo rm libqt5webkit5_5.7.1+dfsg-1_amd64.deb $ sudo apt-get update $ sudo apt-get upgrade

Although we do not recommend this, if you want to nuke ALL of the files in the archive cache -- then this command will do so.

$ sudo apt-get clean   However it is not a bad idea to keep those copies of the original install packages,

  • as a backup,
  • to know for sure what the source files were and
  • as a place to reinstall from if your internet connection is down.

Finally, to remove the unwanted software dependencies,

$ sudo apt-get autoremove

tags: Beginning users, Tips
Footer done in Inkscape