How to find out what installed a certain weak dependency?

Hello,

How can I query dnf to find out why a weak dependency was installed?

As a trivial example, libreoffice-gtk4 is installed as a weak dependency of libreoffice, but if I didn’t know this, how would I find it out?

First, I can confirm that it is a weak dependency by querying the install reason:

$ dnf repoquery --installed --qf '%{reason}\n' libreoffice-gtk4
Weak Dependency

Now, I want to get dnf to tell me that the presence of libreoffice-gtk4 is due to libreoffice. In other words, I want to know this is a Weak Dependency of what?

Here is what I have tried:

Using repoquery with --whatdepends and every other flavour seen in man dnf-repoquery (--whatenhances, --whatrecommends etc.). None of them return anything, with or without the presence of --installed.

$ dnf repoquery --whatdepends libreoffice-gtk4
Updating and loading repositories:
Repositories loaded.

The same, but with the full NEVRA string, which also returns nothing

$ dnf repoquery --whatdepends libreoffice-gtk4-1:24.8.4.2-3.fc41.x86_64
Updating and loading repositories:
Repositories loaded.

We can show that dnf indeed knows this is a dependency of libreoffice by:

Running autoremove, which determines there is nothing to remove.

$ dnf autoremove
Nothing to do.

Checking what will happen if we try and uninstall libreoffice:

$dnf remove libreoffice
Package                         Arch   Version                Reposit      Size
Removing:
 libreoffice                    x86_64 1:24.8.4.2-3.fc41      updates   0.0   B
Removing unused dependencies:
...
 libreoffice-gtk4               x86_64 1:24.8.4.2-3.fc41      updates   1.8 MiB
...

So dnf clearly knows that libreoffice-gtk4 is a weak dependency of libreoffice, and clearly knows that it is only installed because libreoffice is also installed.

If I didn’t already know the parent of a weak dependency, how could I get dnf to tell me?

I am using Fedora 41 with dnf5 version 5.2.8.1.

My version info
$ cat /etc/fedora-release 
Fedora release 41 (Forty One)

$ dnf --version
dnf5 version 5.2.8.1
dnf5 plugin API version 2.0
libdnf5 version 5.2.8.1
libdnf5 plugin API version 2.0

Loaded dnf5 plugins:
name: builddep
version: 1.0.0
API version: 2.0

name: changelog
version: 1.0.0
API version: 2.0

name: config-manager
version: 0.1.0
API version: 2.0

name: copr
version: 0.1.0
API version: 2.0

name: needs_restarting
version: 1.0.0
API version: 2.0

name: repoclosure
version: 1.0.0
API version: 2.0

name: reposync
version: 1.0.0
API version: 2.0

dnf -q rq --providers-of=supplements libreoffice-gtk4

This has been a challenge for me also. Continuing with your libreoffice-gtk4 example

dnf rq --installed --whatdepends libreoffice-gtk4

is the way I normally go about it but

dnf remove libreoffice-gtk4

still finds the information I want more reliably.

1 Like

Indeed the answer for dnf4 is different than the answer for dnf5. Good to keep in mind. I’ve been using f40 and c10s and have only experimented with releases that use dnf5 by default.

The --what*** option limits the output to packages that are required/enhanced/recommended/… by the queried package and not the packages that would require/enhance/recommend/… etc the queried package.

The option you’re looking for, I think, is --supplements:

$ dnf rq --supplements libreoffice-gtk4
Updating and loading repositories:
Repositories loaded.
(libreoffice-core(x86-64) and gtk4(x86-64))

See also:

$ dnf rq --leaves | grep libreoffice
libreoffice-emailmerge-1:24.8.4.2-2.fc41.x86_64
libreoffice-gtk3-1:24.8.4.2-2.fc41.x86_64
libreoffice-gtk4-1:24.8.4.2-2.fc41.x86_64
1 Like

If I didn’t know that the relationship was supplements, what can I do?

Furthermore, this tells me that it supplements libreoffice-core, which is not the ultimate userinstalled package I am looking for, and only coincidentally has an informative name in this scenario.

pkg_deps() {
    for DEP in conflicts depends enhances obsoletes provides \
        recommends requires requires_pre suggests supplements
    do echo "${DEP}": $(dnf -q rq --providers-of="${DEP}" "${@}")
    done
}
pkg_deps libreoffice-gtk4
2 Likes

I see, so the only way to find out what leaf/leaves cause a package to be installed is to iterate all possible relationships, recursively until a leaf is found?

1 Like