#1104141 apt autoremove marks some packages as manual

Package:
apt
Source:
apt
Description:
commandline package manager
Submitter:
inasprecali
Date:
2025-04-25 22:03:03 UTC
Severity:
normal
Tags:
#1104141#5
Date:
2025-04-25 21:37:33 UTC
From:
To:
Dear Maintainer,

Running apt autoremove (or autopurge) resulted in some packages being
marked as manual afterwards, as shown by the output of apt-mark
showmanual.

Here is what happened in my particular situation.

I run the full GNOME desktop environment, obtained by installing the
"gnome" metapackage (not gnome-core).  Some time later, I also
installed the "libreoffice" metapackage.

Afterwards, I noticed that the libreoffice metapackage also pulls in
libreoffice-base and libreoffice-draw, which I am not using.  Since I
noticed that the gnome metapackage depends on the following packages:

- libreoffice-writer
- libreoffice-impress
- libreoffice-draw
- libreoffice-calc

which are the only parts of the LibreOffice suite I use regularly, I
decided to remove the libreoffice metapackage to tidy things up.

To do so, I marked it as "automatically installed" by running
"apt-mark auto libreoffice", then running "apt autoremove"

As expected, packages that were now no longer required, including the
libreoffice metapackage itself, were removed.  To my surprise, the
following packages were later marked as manual according to apt-mark.
Here is the output of apt-mark showmanual | grep libreoffice right
after autoremoval:

libreoffice-calc
libreoffice-core
libreoffice-draw
libreoffice-gtk3
libreoffice-impress
libreoffice-writer

Before autoremoval, only libreoffice-gtk3 was listed, which was
expected since I did install that package manually.

Using autopurge instead of autoremove produces the same result.
Interestingly enough, if I just run "apt autoremove libreoffice"
directly instead of using apt-mark auto and _then_ running apt
atoremove, the issue does not occur: autoremove does not mark any
additional packages as manual.

To summarize, the following commands should be sufficient to reproduce
the issue:

apt install gnome && apt install libreoffice && apt-mark auto libreoffice && apt autoremove

After a brief interaction on the #debian channel on the IRC server
irc.debian.org, another user was able to reproduce the issue on
Trixie.  This bug report specifically refers to Bookworm.

The main question is: is this the expected behavior?

If so, this should be described in detail in the official
documentation, preferably in the manpage.  I couldn't find anything
about this anywhere in the documentation or the internet.

Of course, if this behavior is not expected, it is a genuine bug that
needs to be fixed.

Thank you for your time.

#1104141#10
Date:
2025-04-25 21:59:48 UTC
From:
To:
Control: tag -1 wontfix

Yes.

This is an implementation detail of the solver to not remove entire
desktops and cause systems to become inoperable when a metapackage is
being removed.

i.e. if you just run apt remove libreoffice-writer, it should not remove
your entire gnome desktop, only the metapackage that pulls in
libreoffice-writer and preserve the rest.

I do not think we should be committing to this behavior to the extent
of documenting it, it's a last resort safe guard and not a particularly
good one at that, and we might want to improve on it.

#1104141#17
Date:
2025-04-25 22:02:16 UTC
From:
To:
Control: severity -1 minor

FWIW, if you run apt remove libreoffice, you get the behavior you
were expecting (packages remain automatically installed), this is designed
to be straightforward and feel natural.

You want to remove the package? It will be removed and its dependencies
too if unused.

You want to remove something a metapackage depends on? Only the
metapackage is removed.