Bug#1104141: apt autoremove marks some packages as manual

Julian Andres Klode <[email protected]>
Newsgroups gmane.linux.debian.apt.devel
Message-ID <20250425235437.GA2403322__18848.2146056899$1745618615$gmane$org@debian.org>
Control: tag -1 wontfix

On Fri, Apr 25, 2025 at 11:37:33PM +0200, inasprecali wrote:
> Package: apt
> Version: 2.6.1
> Severity: normal
> X-Debbugs-Cc: [email protected]
> 
> 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?

Yes.

> 
> 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.

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.

-- 
debian developer - deb.li/jak | jak-linux.org - free software dev
ubuntu core developer                              i speak de, en
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.