10

Sometimes when trying to remove a package via 'dnf remove package-name', dnf will list a lot of other packages as 'dependencies' and try to remove them too. I have found that it even does this with seemingly unrelated packages, like removing firewalld somehow declare 'spotify-client' as a dependency.

How do I get dnf to only remove packages related to or installed as dependencies of the package I'm trying to actually remove?

3
  • One thing you'll often run into is similar to buying options on a car. You want to add a radio, but the only way to get the radio is to buy the "luxury package" that includes a sunroof, leather seats, and whitewalls. A lot of Linux distros simplify the build by bundling a collection of packages that people often want. If you installed a barebones version of the distro and then added the package you want, you would probably get just the dependencies. (cont'd)
    – fixer1234
    Apr 11, 2019 at 23:09
  • 1
    But if the distro came with a bunch of stuff in a meta package, removing one item you don't want often triggers removal of that bundle because the dependency logic was figured out at the bundle level.
    – fixer1234
    Apr 11, 2019 at 23:09
  • 1
    @fixer1234 I understand that happens with meta packages but I (for whatever reason) seem to keep encountering that issue with non-meta packages. In addition to the example I gave in my question. I also recently had that issue when removing the newest installed kernel. The system did an update, installed only new kernel package which didn't work on my system. Upon attempting to remove only this newly installed kernel, DNF wanted to remove a lot of unrelated packages along with it. After the fix mentioned below, kernel was removed and everything was good after reboot.
    – Jeff
    Apr 12, 2019 at 6:33

2 Answers 2

16

If you'd like to keep as default the current behavior, and only stop autoremove for specific transactions, you can supply the --noautoremove argument to dnf remove as in:

dnf remove package-name --noautoremove

This is especially useful when autoremove erroneously triggers "unused dependencies".
In my opinion the logic for unused dependencies should have only been libs, never executables, but that ship has sailed long ago.
To modify the default behavior, follow Jeff's solution

3

Edit the file '/etc/dnf/dnf.conf' changing clean_requirements_on_remove=True to clean_requirements_on_remove=False then run dnf clean all.

3
  • So does this remove just the dependencies and not other stuff, or does it leave everything other than the specified package behind?
    – fixer1234
    Apr 11, 2019 at 23:14
  • From what I've seen, it only removes the absolute dependencies and leaves the other stuff.
    – Jeff
    Apr 12, 2019 at 6:30
  • Strange. See dnf.readthedocs.io/en/latest/conf_ref.html. If I'm reading it right, the TRUE setting ought to do what you want. Seems like something isn't working right.
    – fixer1234
    Apr 12, 2019 at 6:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .