Can't install stuff on APT

There's this error that stops me while trying to install software from APT:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  0ad-data 0ad-data-common fonts-texgyre libenet7 libgloox18 libnvtt2
The following NEW packages will be installed:
  0ad 0ad-data 0ad-data-common fonts-texgyre libenet7 libgloox18 libnvtt2
0 upgraded, 7 newly installed, 0 to remove and 26 not upgraded.
4 not fully installed or removed.
Need to get 719 MB/731 MB of archives.
After this operation, 2.140 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://it.archive.ubuntu.com/ubuntu hirsute/universe amd64 0ad-data all 0.0.23.1-1.1 [702 MB]
Get:2 http://it.archive.ubuntu.com/ubuntu hirsute/universe amd64 fonts-texgyre all 20180621-3.1 [10,2 MB]                                                                                                         
Get:3 http://it.archive.ubuntu.com/ubuntu hirsute/universe amd64 0ad-data-common all 0.0.23.1-1.1 [778 kB]                                                                                                        
Get:4 http://it.archive.ubuntu.com/ubuntu hirsute/universe amd64 libenet7 amd64 1.3.13+ds-1 [23,6 kB]                                                                                                             
Get:5 http://it.archive.ubuntu.com/ubuntu hirsute/universe amd64 libgloox18 amd64 1.0.24-2 [378 kB]                                                                                                               
Get:6 http://it.archive.ubuntu.com/ubuntu hirsute/universe amd64 libnvtt2 amd64 2.0.8-1+dfsg-8.2build4 [122 kB]                                                                                                   
Get:7 http://it.archive.ubuntu.com/ubuntu hirsute/universe amd64 0ad amd64 0.0.23.1-5 [5.601 kB]                                                                                                                  
Fetched 719 MB in 1min 19s (9.110 kB/s)                                                                                                                                                                           
Selecting previously unselected package 0ad-data.
(Reading database ... 448647 files and directories currently installed.)
Preparing to unpack .../0-0ad-data_0.0.23.1-1.1_all.deb ...
Unpacking 0ad-data (0.0.23.1-1.1) ...
Selecting previously unselected package fonts-texgyre.
Preparing to unpack .../1-fonts-texgyre_20180621-3.1_all.deb ...
Unpacking fonts-texgyre (20180621-3.1) ...
Selecting previously unselected package 0ad-data-common.
Preparing to unpack .../2-0ad-data-common_0.0.23.1-1.1_all.deb ...
Unpacking 0ad-data-common (0.0.23.1-1.1) ...
Selecting previously unselected package libenet7:amd64.
Preparing to unpack .../3-libenet7_1.3.13+ds-1_amd64.deb ...
Unpacking libenet7:amd64 (1.3.13+ds-1) ...
Selecting previously unselected package libgloox18:amd64.
Preparing to unpack .../4-libgloox18_1.0.24-2_amd64.deb ...
Unpacking libgloox18:amd64 (1.0.24-2) ...
Selecting previously unselected package libnvtt2:amd64.
Preparing to unpack .../5-libnvtt2_2.0.8-1+dfsg-8.2build4_amd64.deb ...
Unpacking libnvtt2:amd64 (2.0.8-1+dfsg-8.2build4) ...
Selecting previously unselected package 0ad.
Preparing to unpack .../6-0ad_0.0.23.1-5_amd64.deb ...
Unpacking 0ad (0.0.23.1-5) ...
Setting up libenet7:amd64 (1.3.13+ds-1) ...
Setting up libgloox18:amd64 (1.0.24-2) ...
dpkg: error processing package linux-headers-5.11.0-22 (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
Setting up fonts-texgyre (20180621-3.1) ...
Setting up 0ad-data (0.0.23.1-1.1) ...
Setting up libnvtt2:amd64 (2.0.8-1+dfsg-8.2build4) ...
Setting up 0ad-data-common (0.0.23.1-1.1) ...
dpkg: dependency problems prevent configuration of linux-headers-5.11.0-22-generic:
 linux-headers-5.11.0-22-generic depends on linux-headers-5.11.0-22; however:
  Package linux-headers-5.11.0-22 is not configured yet.

dpkg: error processing package linux-headers-5.11.0-22-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-headers-generic:
 linux-headers-generic depends on linux-headers-5.11.0-22-generic; however:
  Package linux-headers-5.11.0-22-generic is not configured yet.

dpkg: error processing package linux-headers-generic (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          No apport report written because the error message indicates its a followup error from a previous failure.
 Setting up 0ad (0.0.23.1-5) ...
dpkg: dependency problems prevent configuration of linux-generic:
 linux-generic depends on linux-headers-generic (= 5.11.0.22.23); however:
  Package linux-headers-generic is not configured yet.

dpkg: error processing package linux-generic (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                                              Processing triggers for libc-bin (2.33-0ubuntu5) ...
Processing triggers for man-db (2.9.4-2) ...
Processing triggers for mailcap (3.68ubuntu1) ...
Processing triggers for fontconfig (2.13.1-4.2ubuntu3) ...
Processing triggers for bamfdaemon (0.5.5+21.04.20210119-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for desktop-file-utils (0.26-1ubuntu1) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu1) ...
Errors were encountered while processing:
 linux-headers-5.11.0-22
 linux-headers-5.11.0-22-generic
 linux-headers-generic
 linux-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

Please show the output of df -h .
Also please run sudo apt-get update followed by sudo apt-get install -f with sudo dpkg --configure -a .

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           1,4G  3,5M  1,4G   1% /run
/dev/sdc8        95G   47G   44G  52% /
tmpfs           6,8G   28M  6,8G   1% /dev/shm
tmpfs           5,0M  4,0K  5,0M   1% /run/lock
tmpfs           4,0M     0  4,0M   0% /sys/fs/cgroup
/dev/sdb4       512M   14M  499M   3% /boot/efi
tmpfs           1,4G  164K  1,4G   1% /run/user/1000
/dev/sdd1        58G  2,8G   55G   5% /media/kevinzero/UBUNTU-MATE1
/dev/sde1        58G  918M   57G   2% /media/kevinzero/DTX_64GB_11
/dev/sdf1       118G   17G  102G  15% /media/kevinzero/54E7-1DF0
/dev/sda2       457G  6,7G  427G   2% /media/kevinzero/e810ec0e-c0f9-47c8-adf8-90e63ca42ac01

^ output of df -h

sudo apt-get update runs fine, the other two have the same error as the one showed in my post.

So df -h indicates that you have enough free space.

To fix the issue we can remove problematic packages using low-level commands:

sudo dpkg --force-all --purge  linux-headers-5.11.0-22
sudo dpkg --force-all --purge  linux-headers-5.11.0-22-generic
sudo dpkg --force-all --purge linux-headers-generic

and then reinstall the headers package by

sudo apt-get install linux-headers-generic

and install upgrades then by

sudo apt-get install -f
sudo dpkg --configure -a
sudo apt-get dist-upgrade # to get new dependencies
1 Like