While doing other maintenance tasks I noticed that dpkg -l
listed about 90 packages with status ri
instead of expected ii
.
I maintain packages solely with apt
and aptitude
and I haven't forced any packages but I regulary do apt install --no-install-recommends ...
to avoid getting unneeded packages. I also try to carefully maintain the "automatically installed" flags and I have 2914 packages with status "automatically installed" (aptitude search '~i~M'
) and 422 packages with status "manually installed" (aptitude search '~i!~M'
).
What could be the reason for packages to have status Remove
+ Inst
(ri
) in dpkg -l
listing when I haven't requested those packages to be removed? It seemed that the packages with this status were packages that I actually want to keep in the system. Could e.g. sudo apt dist-upgrade
cause this without me noticing?
(I know that I can reinstall those packages with apt install --reinstall package-name
to get status back to ii
. I also often purge removed packages and aptitude search '~c'
lists no packages.)
Additional details from another system with the same issue:
$ sudo apt dist-upgrade && sudo apt autoremove && dpkg -l | grep ^ri | wc -l
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
virtualbox-6.0
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
171
So dist-upgrade
nor autoremove
do not touch the 171 packages with ri
status.
Example package with ri
status:
$ dpkg -l ca-certificates-java
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-===============================================-============================-============================-===================================================================================================
ri ca-certificates-java 20160321ubuntu1 all Common CA certificates (JKS keystore)
and additional info for the same package:
$ aptitude show ca-certificates-java
Package: ca-certificates-java
State: installed
Automatically installed: no
Multi-Arch: foreign
Version: ...
$ aptitude why ca-certificates-java
i default-jre-headless Depends openjdk-8-jre-headless
iBA openjdk-8-jre-headless Depends ca-certificates-java
$ apt-mark showhold
virtualbox-6.0
Additional info after reading about possible causes:
As explained in answer https://askubuntu.com/a/802612/50254 the status of these packages can be fixed to match currently installed packages by running (note that the line feed after IFS
is not a typo but this command requires setting IFS
to single linefeed):
export IFS='
'
for i in $(dpkg -l |egrep '^[a-z]i.*' |awk '{print $2" install"}') ; do echo $i|dpkg --set-selections ; done
unset IFS
The reason/cause for this problem is still unknown. The ri
status is supposed to mean that dselect
(old debian package manager nowadays completely replaced by apt
) has used to mark package to be removed from the system and if you actually want to apply those selection states you can run apt-get dselect-upgrade
. See man dpkg
and section "INFORMATION ABOUT PACKAGES" for more information.
The apt install --reinstall package-name
is also okay but it will do more than the minimum change to system to fix the problem.