Score:0

dpkg attempting to uninstall an unexisting package

cn flag
Sam

dpkg pre-removal exit status 1 for linux-modules-nvidia-390-5.8.0-59-generic

I tried sudo apt update, sudo apt upgrade, and here's the problem.

$ sudo apt upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 linux-modules-nvidia-390-5.8.0-59-generic : Depends: nvidia-kernel-common-390 (<=390.143-1) but 390.157-0ubuntu0.20.04.1 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

Then I followed the instructions. sudo apt --fix-broken install

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages will be REMOVED:
  linux-modules-nvidia-390-5.8.0-59-generic
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 32.8 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 292270 files and directories currently installed.)
Removing linux-modules-nvidia-390-5.8.0-59-generic (5.8.0-59.66~20.04.1) ...
/var/lib/dpkg/info/linux-modules-nvidia-390-5.8.0-59-generic.prerm: 14: cd: can'
t cd to /lib/modules/5.8.0-59-generic/kernel/nvidia-390/bits
dpkg: error processing package linux-modules-nvidia-390-5.8.0-59-generic (--remo
ve):
 installed linux-modules-nvidia-390-5.8.0-59-generic package pre-removal script 
subprocess returned error exit status 1
dpkg: too many errors, stopping
Errors were encountered while processing:
 linux-modules-nvidia-390-5.8.0-59-generic
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)

I've also tried this. sudo dpkg -P linux-modules-nvidia-390-5.8.0-59-generic

(Reading database ... 292270 files and directories currently installed.)
Removing linux-modules-nvidia-390-5.8.0-59-generic (5.8.0-59.66~20.04.1) ...
/var/lib/dpkg/info/linux-modules-nvidia-390-5.8.0-59-generic.prerm: 14: cd: can't cd to /lib/modules/5.8.0-59-generic/kernel/nvidia-390/bits
dpkg: error processing package linux-modules-nvidia-390-5.8.0-59-generic (--purge):
 installed linux-modules-nvidia-390-5.8.0-59-generic package pre-removal script subprocess returned error exit status 1
Errors were encountered while processing:
 linux-modules-nvidia-390-5.8.0-59-generic

I've also tried these (with sudo) and they don't work.

apt autoremove
apt autoclean
sudo dpkg --force-all -P linux-modules-nvidia-390-5.8.0-59-generic
apt autoremove -f
apt --fix-broken install
sudo apt full-upgrade

I also tried the GUI updater.enter image description here (translate: not all update can be installed) enter image description here (translate: apt index broken)

PS: I am not sure if this is related. This happened alongside. Screen glitches after an apt update

UPDATE: It seemed that the package concerned has been removed by someone (livepatch maybe?) but it wasn't unregistered in dpkg/apt directory.

Is there a way to update dpkg/apt directory so it can be marked as not installed?

ChanganAuto avatar
us flag
Try `sudo apt full-upgrade`
user535733 avatar
cn flag
Don't misuse `--purge` (`-P`). It is not a forcing command. It does one specific action, and that's not the action you want.
user535733 avatar
cn flag
The problem seems right there in your output: `cd: can't cd to /lib/modules/5.8.0-59-generic/kernel/nvidia-390/bits` . There's one or more directories missing. One solution is to create them so the script can run without error.
Sam avatar
cn flag
Sam
`sudo apt full-upgrade` cannot work. @ChanganAuto Similar output.
Sam avatar
cn flag
Sam
@user535733 I tired to creat the directory above, but it don't work. It then calls a `.\CLEAN` script in that dir.
user535733 avatar
cn flag
"*it don't work*" suggest that you need to investigate or to try something else or to provide mode detail...in your Question (not in comments). Comments are intended to help you improve your question until it is answerable. Comments are not intended to be answers.
Score:0
cn flag
Sam

Since the package no longer exists, (Maybe uninstalled by livepatch?), all I have to do is to remove it from the directory.
So I edited /var/lib/dpkg/status. I removed these lines.

Package: linux-modules-nvidia-390-5.8.0-59-generic
Status: deinstall ok installed
Priority: optional
Section: kernel
Installed-Size: 32
Maintainer: Canonical Kernel Team <kernel-team@lists.ubuntu.com>
Architecture: amd64
Source: linux-restricted-modules-hwe-5.8
Version: 5.8.0-59.66~20.04.1
Depends: debconf (>= 0.5) | debconf-2.0, linux-image-5.8.0-59-generic | linux-image-unsigned-5.8.0-59-generic, linux-signatures-nvidia-5.8.0-59-generic (= 5.8.0-59.66~20.04.1), linux-objects-nvidia-390-5.8.0-59-generic (= 5.8.0-59.66~20.04.1), nvidia-kernel-common-390 (<= 390.143-1), nvidia-kernel-common-390 (>= 390.143)
Description: Linux kernel nvidia modules for version 5.8.0-59
 This package pulls together the Linux kernel nvidia modules for
 version 5.8.0-59 with the appropriate signatures.
 .
 You likely do not want to install this package directly. Instead, install the
 one of the linux-modules-nvidia-390-generic* meta-packages,
 which will ensure that upgrades work correctly, and that supporting packages are also installed.

Then the apt directory is fixed, and the methods above (such as sudo apt full-upgrade) works.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.