Dnf mark group doesn't make package part of a group

dnf mark group <package-spec>…
Marks the specified packages as installed by group. This can be useful if any package was installed as a dependency or a user and is desired to be protected and handled as a group member like during group remove.[1]

However after my saga on trying to understand the group mark [2], I’m kinda convinced that this is broken (or doesn’t do what it says).

$ dnf repoquery --whatdepends flatpak --installed
fedora-flathub-remote-0:1-6.fc39.noarch
gnome-software-0:45.2-1.fc39.x86_64
$ sudo dnf remove fedora-flathub-remote
$ sudo dnf remove gnome-software
# Wants to remove flatpak, cancelled.

$ dnf repoquery --groupmember flatpak
flatpak-1.15.6-1.fc39.x86_64
  @container-management
# Fedora Workstation has container-management by default.
$ sudo dnf mark group flatpak
$ sudo dnf remove gnome-software
# Does not remove flatpak, good.

$ sudo dnf group remove container-management
# Does not want to remove flatpak, what?!

# Checking
$ dnf repoquery --whatdepends flatpak --installed
# Nothing
$ dnf repoquery --installed --qf='%{name}-%{evr}.%{arch} (%{reason})' flatpak
flatpak-1.15.6-1.fc39.x86_64 (group)

  1. https://dnf.readthedocs.io/en/latest/command_ref.html#mark-command ↩︎

  2. 1 2 3 ↩︎

This is the first I’ve heard of dnf mark group, but maybe it’s because flatpak is only an optional member of that group.

1 Like

I tried it on a Live USB and it works as expected:

$ sudo dnf mark group flatpak
$ sudo dnf remove fedora-flathub-remote gnome-software
$ sudo dnf remove @container-management
# See flatpak in the remove list.

I think what happened was that I used sudo dnf group mark remove container-management before, which irrecoverably made those packages orphaned.

$ sudo dnf group mark remove container-management
$ sudo dnf group install container-management
$ sudo dnf group remove container-management
# Nothing in the list!
# Try everything, but it will never work again...

EDIT:
sudo dnf group install container-management --with-optional can fix it, but will need to install all optional packages.