1

First of all, I believe I should say that I just installed Ubuntu 18.04 LTS earlier this week so I basically don't know anything.
I was installing the python3 idle today and encountred an error:

dpkg: error processing package linux-modules-4.15.0-22-generic (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          dpkg: dependency problems prevent configuration of linux-image-4.15.0-22-generic:
 linux-image-4.15.0-22-generic depends on linux-modules-4.15.0-22-generic; however:
  Package linux-modules-4.15.0-22-generic is not configured yet.

dpkg: error processing package linux-image-4.15.0-22-generic (--configure):
 dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.27-3ubuntu1) ...
dpkg: dependency problems prevent configuration of linux-modules-extra-4.15.0-22-generic:
 linux-modules-extra-4.15.0-22-generic depends on linux-image-4.15.0-22-generic | linux-image-unsigned-4.15.0-22-generic; however:
  Package linux-image-4.15.0-22-generic is not configured yet.
  Package linux-image-unsigned-4.15.0-22-generic is not installed.

dpkg: error processing package linux-modules-extra-4.15.0-22-generic (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Processing triggers for man-db (2.8.3-2) ...
Processing triggers for gnome-menus (3.13.3-11ubuntu1) ...
Setting up libtcl8.6:amd64 (8.6.8+dfsg-3) ...
dpkg: dependency problems prevent configuration of linux-image-generic:
 linux-image-generic depends on linux-image-4.15.0-22-generic; however:
  Package linux-image-4.15.0-22-generic is not configured yet.
 linux-image-generic depends on linux-modules-extra-4.15.0-22-generic; however:
  Package linux-modules-extra-4.15.0-22-generic is not configured yet.

dpkg: error processing package linux-image-generic (--configure):
 dependency problems - leaving unconfigured
Setting up libtk8.6:amd64 (8.6.8-4) ...
No apport report written because MaxReports is reached already
                                                              Setting up tk8.6-blt2.5 (2.5.3+dfsg-4) ...
dpkg: dependency problems prevent configuration of linux-generic:
 linux-generic depends on linux-image-generic (= 4.15.0.22.23); however:
  Package linux-image-generic is not configured yet.

dpkg: error processing package linux-generic (--configure):
 dependency problems - leaving unconfigured
Setting up blt (2.5.3+dfsg-4) ...
No apport report written because MaxReports is reached already
                                                              Setting up python3-tk:amd64 (3.6.5-3) ...
Setting up idle-python3.6 (3.6.5-3) ...
Setting up idle (3.6.5-3) ...
Setting up idle3 (3.6.5-3) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Errors were encountered while processing:
 linux-modules-4.15.0-22-generic
 linux-image-4.15.0-22-generic
 linux-modules-extra-4.15.0-22-generic
 linux-image-generic
 linux-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

So I ran Sudo apt-get upgrade thinking it's just about upgrading the linux modules and I got the same error message. I look up the error message online and I find this post that has the same error message. So I first ran the command the asker used: sudo apt-get install -f and got this error message:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
5 not fully installed or removed.
Need to get 0 B/12.9 MB of archives.
After this operation, 0 B of additional disk space will be used.
dpkg: error processing package linux-modules-4.15.0-22-generic (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
dpkg: dependency problems prevent configuration of linux-image-4.15.0-22-generic:
 linux-image-4.15.0-22-generic depends on linux-modules-4.15.0-22-generic; however:
  Package linux-modules-4.15.0-22-generic is not configured yet.

dpkg: error processing package linux-image-4.15.0-22-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.
                                            dpkg: dependency problems prevent configuration of linux-modules-extra-4.15.0-22-generic:
 linux-modules-extra-4.15.0-22-generic depends on linux-image-4.15.0-22-generic | linux-image-unsigned-4.15.0-22-generic; however:
  Package linux-image-4.15.0-22-generic is not configured yet.
  Package linux-image-unsigned-4.15.0-22-generic is not installed.

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

dpkg: error processing package linux-image-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-genNo apport report written because MaxReports is reached already
                                                                                                                          No apport report written because MaxReports is reached already
                eric:
 linux-generic depends on linux-image-generic (= 4.15.0.22.23); however:
  Package linux-image-generic is not configured yet.

dpkg: error processing package linux-generic (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 linux-modules-4.15.0-22-generic
 linux-image-4.15.0-22-generic
 linux-modules-extra-4.15.0-22-generic
 linux-image-generic
 linux-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

Which from what I understood differs a bit from the first in that the first said the package is not configured and the second said I should reinstall it because it's in a bad state before configuring. It gives an almost identical error message to that of the asker. so I tried the steps mentioned in the accepted answer. I ran this command sudo rm /etc/apt/sources.list and then this one sudo software-properties-gtkand I get this error message:

WARNING:root:could not open file '/etc/apt/sources.list'

WARNING:root:could not open file '/etc/apt/sources.list'

So I wrote the second command again and it opened software-properties-gtk and wrote this into the terminal:

 Gtk-Message: 20:43:48.389: GtkDialog mapped without a transient parent. This is discouraged.

So I used these settings. I hit Revert, nothing happened. I hit it again and still nothing happened. So, I hit Close and got this error message/notification. I realized that I can't follow with that tutorial because he just purged chrome and I can't purge linux modules. So, I reran sudo apt-get -f install and now, it shows a way shorter error message:

    Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: The package linux-modules-4.15.0-22-generic needs to be reinstalled, but I can't find an archive for it. 

I tried sudo apt-get clean and nothing showed up on the terminal and then I tried to use this command I saw on this post: sudo apt-get install --reinstall linux-modules-4.15.0-22-generic I don't know if that's the name of the package to reinstall but it was worth a try. I got the same error message.

Did I break something? Do I need to reformat my system?

Edit: Output of ls -la /etc/apt/sources.list is -rw-r--r-- 1 root root 84 May 26 20:43 /etc/apt/sources.list

Output of uname -a is Linux Oussema 4.15.0-20-generic #21-Ubuntu SMP Tue Apr 24 06:16:15 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

  • Try please the following commands in succesion of each other: sudo apt clean, sudo apt update, sudo apt install --reinstall linux-generic. As of now there is a newer kernel available. Other problem which could have been is that the packages where corrupted as you downloaded them while updating. – Videonauth May 26 '18 at 21:27
  • It tells me E: The package linux-modules-4.15.0-22-generic needs to be reinstalled, but I can't find an archive for it. – Oussema May 26 '18 at 21:30
  • What is the output of ls -la /etc/apt/sources.list? if you get an empty line you need to recreate your sources.list file. Just tell me. And pleas edit your question to include the output of uname -a. – Videonauth May 26 '18 at 21:35
  • Output of ls -la /etc/apt/sources.list is -rw-r--r-- 1 root root 84 May 26 20:43 /etc/apt/sources.list Output of uname -a is Linux Oussema 4.15.0-20-generic #21-Ubuntu SMP Tue Apr 24 06:16:15 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux – Oussema May 26 '18 at 21:39
  • And sorry to bother you what is the output of cat /etc/apt/sources.list ? – Videonauth May 26 '18 at 22:00
5

From the comments I can read that you have cleaned out your sources.list file, so let's fix this first by copying the following block over into your terminal:

sudo su
cat > /etc/apt/sources.list << "EOF"
deb http://archive.ubuntu.com/ubuntu bionic main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu bionic main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu bionic-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu bionic-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu bionic-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu bionic-backports main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu bionic-proposed main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu bionic-proposed main restricted universe multiverse
deb http://archive.canonical.com/ubuntu bionic partner
deb-src http://archive.canonical.com/ubuntu bionic partner
EOF
exit

Now we can begin to fix your installation which seems to have ended up in a weird state.

First remove the removable packages after having run an update to get the proper package archives updated:

sudo apt update
sudo apt autoremove --purge

This should remove all removable packages so far except the one which managed to get messed up which we can then remove then by installing it and then removing it properly:

cd /var/cache/apt/archives
sudo dpkg -i linux-modules-4.15.0-22-generic_4.15.0-22.24_amd64.deb
sudo dpkg -r linux-modules-4.15.0-22-generic_4.15.0-22.24_amd64.deb

Now cleaning up the archives by running:

sudo apt clean

And now we can reinstall the packages properly after having run an complete update process:

sudo apt update
sudo apt dist-upgrade

with the following line:

sudo apt install --reinstall linux-generic

This should have fixed your system into a complete working state again. Have fun and welcome to the Linux community.

0

I've had this issue twice now with two different versions of this image. See my fix here: https://askubuntu.com/a/1141915/954416

I had this issue on two separate machines today after doing an apt update and apt upgrade except mine was for linux-image-4.15.0-48-generic. (Ubuntu 18.04.2)

My fix was this (reproduced on both machines):

sudo rm /var/lib/dpkg/info/linux-image-4.15.0-48-generic.postinst
sudo dpkg --configure -a
sudo apt-get update

Then reinstall the package:

sudo apt install linux-image-4.15.0-48-generic

This will set the package to manually installed and will replace the *.postinst file.

New contributor
Ben Molloy is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • Please include essential parts here. – Codito ergo sum May 16 at 13:45
  • @Coditoergosum - edited/updated. – Ben Molloy May 16 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.