Dnf ignore weak dependencies


dnf --setopt=install_weak_deps=False --best install newpackage

dnf do not install weak dependencies

In the new paradigm for rpm package management (rpmpm?), we use dnf. I am fine with using the latest and greatest, but sometimes yum looks nicer in hindsight than dnf.

One of the more recent features added to rpms is weak dependencies. Debian has had weak dependencies for a longer time, so it’s nice to see rpm adding such a feature.

I recently went through a spell where I wanted to install my own package but exclude the recommended options.

After a lot of research and man dnf dnf.conf, I derived the command I needed.

dnf --setopt=install_weak_deps=False --best install newpackage


I tried an ugly hack, which technically worked.

dnf --disablerepo=* install ./bgscripts*

But all it does is disable all repos. I was using a local file, so it could get to the rpm I required, but any hard dependencies would be not found. I then tried another option, which technically worked.

dnf install ./bgscripts* -x freerdp

But I had to run a dnf command to see what packages would be installed, and then manually named the packages in the exclude list.



  1. https://fedoraproject.org/wiki/PackagingDrafts/WeakDependencies
  2. https://www.debian.org/doc/debian-policy/ch-relationships.html

Man pages



2 thoughts on “Dnf ignore weak dependencies

  1. Thanks a lot for your tutorial. It helped me solve a problem with vagrant package that was forcing me to install vagrant-libvirt at the same time.

    It’s not clear to me why you recommend –best.
    In what situation do you use it?
    To me, dnf already try to install the latest version. And if you want an older one you could use –showduplicates.

    Is it because –best displays a reason why the latest version can not be installed. But isn’t it always the case?

    • I would have used this when I was trying to install my bgscripts package as described under the “History” heading of this article. Bgscripts had a weak dependency on xfreerdp, but I didn’t want to bother to install xfreerdp on the system in question. I don’t specifically remember why “–best” is used here though. From the man page:

      -b, –best
      Try the best available package versions in transactions. Specifically during dnf upgrade, which by default skips over updates that can not be
      installed for dependency reasons, the switch forces DNF to only consider the latest packages. When running into packages with broken dependencies,
      DNF will fail giving a reason why the latest version can not be installed.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.