• Bug#1055190: apt: autoremove forgets a package

    From Vincent Lefevre@21:1/5 to Vincent Lefevre on Sun Apr 21 03:40:01 2024
    Control: found -1 2.9.1

    On 2023-11-01 21:53:26 +0100, Vincent Lefevre wrote:
    Package: apt
    Version: 2.6.1
    Severity: normal

    I've installed several -perl packages with "apt install", including libio-async-perl, and libtest-fatal-perl:amd64 was automatically
    installed as a dependency:

    Start-Date: 2023-11-01 21:03:35
    Commandline: apt install libio-async-perl
    Install: libdevel-mat-dumper-perl:amd64 (0.46-1+b1, automatic), libio-async-perl:amd64 (0.802-1), libtest-fatal-perl:amd64 (0.017-1, automatic), libtest-metrics-any-perl:amd64 (0.01-2, automatic), libsereal-perl:amd64 (5.003-1, automatic), libmetrics-
    any-perl:amd64 (0.09-1, automatic), libstruct-dumb-perl:amd64 (0.14-1, automatic), libtest-refcount-perl:amd64 (0.10-4, automatic), libasync-mergepoint-perl:amd64 (0.04-4, automatic)
    End-Date: 2023-11-01 21:03:39

    A bit later, I found that this was not needed, so that I removed the
    packages and also did a "apt autoremove --purge". Now, this command
    says:

    root@qaa:~# apt autoremove --purge
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

    but while libtest-fatal-perl:amd64 (from /var/log/apt/history.log
    above) isn't installed, libtest-fatal-perl still is:

    root@qaa:~# dpkg -s libtest-fatal-perl:amd64
    dpkg-query: package 'libtest-fatal-perl' is not installed and no information is available
    Use dpkg --info (= dpkg-deb --info) to examine archive files.

    root@qaa:~# dpkg -s libtest-fatal-perl
    Package: libtest-fatal-perl
    Status: install ok installed
    Priority: optional
    Section: perl
    Installed-Size: 43
    Maintainer: Debian Perl Group <pkg-perl-maintainers@lists.alioth.debian.org> Architecture: all
    Multi-Arch: foreign
    Version: 0.017-1
    Depends: perl:any, libtry-tiny-perl

    Well, this isn't really the right explanation. This is due to an
    output bug in apt, which should have output "libtest-fatal-perl:all"
    instead of "libtest-fatal-perl:amd64".

    So "apt autoremove" forgot it.

    And I can reproduce the issue on another machine:

    disset:~> apt-mark showauto | grep libtest-fatal-perl
    libtest-fatal-perl

    disset:~> apt autoremove -s
    NOTE: This is only a simulation!
    apt needs root privileges for real execution.
    Keep also in mind that locking is deactivated,
    so don't depend on the relevance to the real current situation!
    Summary:
    Upgrading: 0, Installing: 0, Removing: 0, Not Upgrading: 18

    disset:~> aptitude why libtest-fatal-perl
    i libmastodon-client-perl Depends libdatetime-perl
    i A libdatetime-perl Depends libspecio-perl
    i A libspecio-perl Suggests libtest-fatal-perl

    disset:~> aptitude remove -s libtest-fatal-perl
    The following packages will be REMOVED:
    libtest-fatal-perl
    0 packages upgraded, 0 newly installed, 1 to remove and 18 not upgraded.
    Need to get 0 B of archives. After unpacking 44.0 kB will be freed.
    Would download/install/remove packages.

    So, there's only a "Suggests", and note that I do not install
    "Suggests" by default.

    The only place this package appears in the history is

    Start-Date: 2024-01-06 02:53:49
    Commandline: apt install libhtml-gumbo-perl libidn-dev libimage-exiftool-perl libipc-run-perl liblinux-inotify2-perl libmastodon-client-perl
    Install: libdevel-mat-dumper-perl:amd64 (0.47-1, automatic), libclass-load-perl:amd64 (0.25-2, automatic), libsafe-isa-perl:amd64 (1.000010-1, automatic), libmastodon-client-perl:amd64 (0.017-2), libhash-multivalue-perl:amd64 (0.16-3, automatic),
    libimage-base-bundle-perl:amd64 (1.0.7-3.5, automatic), libio-async-perl:amd64 (0.802-2, automatic), libtest-fatal-perl:amd64 (0.017-1, automatic), pkgconf:amd64 (1.8.1-1, automatic), libtest-metrics-any-perl:amd64 (0.01-2, automatic), libcompress-raw-
    lzma-perl:amd64 (2.206-2, automatic), libsereal-perl:amd64 (5.004-1, automatic), libio-async-ssl-perl:amd64 (0.25-1, automatic), libidn-dev:amd64 (1.41-1), libhtml-gumbo-perl:amd64 (0.18-3+b2), libimage-info-perl:amd64 (1.44-1, automatic), libimage-
    exiftool-perl:amd64 (12.67+dfsg-1), libmetrics-any-perl:amd64 (0.10-1, automatic), libcompress-bzip2-perl:amd64 (2.28-1+b3, automatic), pkg-config:amd64 (1.8.1-1, automatic), libfuture-perl:amd64 (0.50-1, automatic), liblinux-inotify2-perl:amd64 (1:2.3-2)
    , libstruct-dumb-perl:amd64 (0.14-1, automatic), pkgconf-bin:amd64 (1.8.1-1, automatic), libtypes-path-tiny-perl:amd64 (0.006-2, automatic), libtest-refcount-perl:amd64 (0.10-4, automatic), libpkgconf3:amd64 (1.8.1-1, automatic), libasync-mergepoint-perl:
    amd64 (0.04-4, automatic), libhttp-thin-perl:amd64 (0.006-2, automatic), libnet-async-http-perl:amd64 (0.49-1, automatic), librole-eventemitter-perl:amd64 (0.003-2, automatic), libfuture-xs-perl:amd64 (0.12-1, automatic), libfuture-io-perl:amd64 (0.15-1,
    automatic)
    End-Date: 2024-01-06 02:53:54

    I suppose that libtest-fatal-perl was automatically installed
    because libio-async-perl 0.802-2 recommended it. But this
    "Recommends" was removed in libio-async-perl 0.803-1, which
    is currently installed on this machine.

    In the "Reverse Depends" listed by "apt-cache showpkg libtest-fatal-perl",
    only 2 packages are installed (libspecio-perl and libio-async-perl),
    but this is a "Suggests" in both cases.

    --
    Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
    100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
    Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Vincent Lefevre@21:1/5 to David Kalnischkies on Mon Apr 22 03:30:01 2024
    On 2024-04-21 12:03:05 +0200, David Kalnischkies wrote:
    On Sun, Apr 21, 2024 at 03:35:28AM +0200, Vincent Lefevre wrote:
    root@qaa:~# dpkg -s libtest-fatal-perl:amd64
    dpkg-query: package 'libtest-fatal-perl' is not installed and no information is available
    Use dpkg --info (= dpkg-deb --info) to examine archive files.
    [...]
    Well, this isn't really the right explanation. This is due to an
    output bug in apt, which should have output "libtest-fatal-perl:all" instead of "libtest-fatal-perl:amd64".

    That might be your preference (now), but it would be wrong in terms of
    apt and I am sure if you think a bit more about it you will agree:

    A package is not arch:all. People say that all the time, but only
    because they mean that "this version of the package is arch:all" as we
    tend to talk about a *.deb file as a package and that contains
    a specific version.

    If apt were to display "libtest-fatal-perl:all" it would mean that if
    that package becomes arch:any in the next version apt would need
    to show "removing: libtest-fatal-perl:all" and "new install: libtest-fatal-perl:amd64" instead of as an "upgrade" among many other
    very annoying things around architectures.

    So, for apt, "libtest-fatal-perl:all" is treated like "libtest-fatal-perl:native" aka "libtest-fatal-perl:amd64" for you, so
    that if a binary package is arch:any or arch:all is an implementation
    detail for a user – as it should be – as that changes over time.
    The native architecture does not change as often, if at all.

    So, in other words, for apt a "package" is usually a set of versions
    which can have different architectures, while for dpkg a package is
    a single version (except if it is not, like in that same arch:all to
    arch:any flip; but users don't speak to dpkg that often and especially
    not in that moment. apt does for them…).

    In a way, you could complain that dpkg is so anal about the arch
    instead, but in its own world and context, it makes sense.

    But here, "apt install ..." outputs libtest-fatal-perl:amd64, which is
    a particular version of this package. And just after the installation,
    "dpkg -s ..." refers to exactly the same version. So one should expect
    that both tools use a common name to designate the package.

    So, there's only a "Suggests", and note that I do not install
    "Suggests" by default.

    While you don't install Suggests via `APT::Install-Suggests` which is
    `false` by default, that has no bearing on the autoremoval.

    Controlling autoremoval behaviour is `APT::AutoRemove::SuggestsImportant` which defaults to `true` as the autoremover could potentially break some usecase for you that the suggests enabled and you have grown attached to
    even through the suggests was once installed for another reason.

    OK, I had actually that on my old machines, but for some reason,
    I didn't remember that and didn't notice that this was missing on
    new machines (and there was a bug in my script that checked the
    consistency of the config between machines).

    But the fact that this is a hidden setting did not help, i.e. it is
    not mentioned in the documentation (apt(8), apt-get(8), apt.conf(5), apt-config(8) man pages, APT User's Guide), while the description of
    "apt autoremove" is misleading ("dependencies" is used twice in the
    same sentence with 2 different meanings!).

    --
    Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
    100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
    Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Vincent Lefevre@21:1/5 to Vincent Lefevre on Mon Apr 22 03:40:02 2024
    On 2024-04-22 03:19:36 +0200, Vincent Lefevre wrote:
    On 2024-04-21 12:03:05 +0200, David Kalnischkies wrote:
    Controlling autoremoval behaviour is `APT::AutoRemove::SuggestsImportant` which defaults to `true` as the autoremover could potentially break some usecase for you that the suggests enabled and you have grown attached to even through the suggests was once installed for another reason.

    OK, I had actually that on my old machines, but for some reason,
    I didn't remember that and didn't notice that this was missing on
    new machines (and there was a bug in my script that checked the
    consistency of the config between machines).

    I meant that I had

    APT::AutoRemove::SuggestsImportant "false";

    in a config file on old machines (added 6 years ago), but this
    file was missing on the new machines, and I did not remember of
    the existence of this setting because:

    But the fact that this is a hidden setting did not help, i.e. it is
    not mentioned in the documentation (apt(8), apt-get(8), apt.conf(5), apt-config(8) man pages, APT User's Guide), while the description of
    "apt autoremove" is misleading ("dependencies" is used twice in the
    same sentence with 2 different meanings!).

    --
    Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
    100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
    Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)