How to remove unneeded dependencies from uninstalled packages using zypper?

By consulting “zypper help rm” there’s the “-u” option, but it demands a package (uninstalled package?) as argument.

Other distributions such as Debian, RedHat, and based on them, have the “autoremove” function in their corresponding package manager tools, which works quite well.

Is there not another way in openSUSE other than “zypper rm -u ”?

Thanks.

Just leave them. They don’t hurt.

Otherwise search for a similar thread a few days ago.

I just use Yast. If you select - yast / software management / view / package classification and then look under the orphaned & unneeded package groups, they are listed and can be remoced as required.

Few days ago?
Probably you meant LONG ago… because I’m still searching

I know this can be done with Yast, but I’m learning zypper, thanks

By opening the man pages of zypper and searching for “unneeded” you will get wiser. “orphaned” is another search term. This also applies for the forum with countless actual results…

Few days ago?
Probably you meant LONG ago… because I’m still searching

I know this can be done with Yast, but I’m learning zypper, thanks

1 Like

@F_style:

If you didn’t use the “-u” option (“–clean-deps”) option when removing packages then you’ll have to search for packages which no longer have any “requires” or, “recommended” or, “suggested” package dependencies.

Please note that, packages tagged as being “unwanted” or, “orphaned” or, “dropped” are something else …

AFAICS, the only reliable method of cleaning out unused dependencies will be to use RPM in a script –

  • List all the installed packages and then –
  • For each installed package execute “rpm --query --whatrequires/recommends/suggests”.
    Those packages which are not required (by) or, recommended (by) or, suggested (by) anything can be safely removed.

You’ll also have to search ‘/var/log/zypp/history’ for entries indicating what was also installed when you installed the package which you removed without cleaning up the dependencies – just to be on the safe side …


You could also reinstall the packages you removed and then, remove them again but, this time with the “–clean-deps” option …

1 Like

But won’t this return every package that isn’t a dependency?

Isn’t what we want packages that were installed as dependency but no longer have anything dependent on them?

1 Like

And how would you detect such a thing that happened in the past?

You can now find out that a package is now not wanted by any other. But you do not know if it was some time in the past. Except when you keep all sorts of history/logs.

It sounds like the issue here is that it isn’t being tracked by the package manager.

Other package managers do track that so it is possible with those package managers.

If it is true that the package manager doesn’t track it, then the answer to the OP’s question may simply be it isn’t possible to do that on OpenSUSE as it is on many other distros.

It is (otherwise zypper remove --clean-deps were not possible), but there is no zypper command to do the equivalent of apt autoremove. The question pops up for years and I do not remember anyone actually submitting feature request.

Unneeded packages installed automatically can cause trouble. On infamous host erlangen I run the following for removing them:

erlangen:~ # alias rmu
alias rmu='zypper packages --unneeded | grep ^i|cut -d '\''|'\'' -f3|xargs zypper rm --clean-deps'
erlangen:~ # 

See also Command to clean out all unneeded autoinstalled dependencies · Issue #116 · openSUSE/zypper · GitHub

1 Like

Correct.

My mistake – mea culpa, mea culpa, mea maxima culpa.


Digging further after I posted that suggestion, I stumbled across the following (note the use of a “normal” user with no system administration rights) –

> rpm --erase --test «PACKAGE NAME»

It’s rather nice – it checks which included objects have dependencies to other packages.

  • Please note that, the equivalent Zypper command – “zypper remove --dry-run «PACKAGE NAME»” requires “root” privileges …

Please be aware that, the output of the RPM --erase command, is sent to standard error –

  • Meaning that, to check the complete system, a script is needed which writes the package name and the standard error output to a file, which then needs to be checked for packages which didn’t produce any information sent to standard error –
 > rpm --erase --test aaa_base
error: Failed dependencies:
        aaa_base is needed by (installed) google-poppins-fonts-4.003-6.3.1.noarch
        aaa_base is needed by (installed) dmraid-1.0.0.rc16-3.26.x86_64
        aaa_base = 84.87+git20180409.04c9dae is needed by (installed) aaa_base-extras-84.87+git20180409.04c9dae-150300.10.3.1.x86_64
        aaa_base is needed by (installed) desktop-file-utils-0.26-150400.1.7.x86_64
        aaa_base is needed by (installed) ghostscript-fonts-std-9.06-14.3.1.noarch
        aaa_base is needed by (installed) parallel-printer-support-1.00-bp155.2.9.noarch
        aaa_base is needed by (installed) patterns-base-base-20200505-lp155.10.5.x86_64
        aaa_base >= 13.2 is needed by (installed) systemd-249.16-150400.8.28.3.x86_64
        /etc/mime.types is needed by (installed) apache2-2.4.51-150400.6.11.1.x86_64
        /sbin/chkconfig is needed by (installed) dhcp-4.3.6.P1-150000.6.17.1.x86_64
        /usr/bin/get_kernel_version is needed by (installed) dracut-055+suse.366.g14047665-150500.3.6.1.x86_64
 >

Nice programming exercise if you have time enough. But if the few MBs are worth it?

IMO, keeping the system clean of unneeded packages has multiple benefits in addition to the saved space

  • It makes updates faster and use less bandwidth - A real issue if you are on a metered connection
  • Less packages installed means less potential for future package conflicts, especially when those packages have become obsolete
  • It gives me peace of mind :nerd_face:
1 Like

Henk, it ain’t the disk resources being used –

  • It’s the unneeded, out-of-date, extraneous and, unmaintained code, located in system binary and library directories …

If it’s executable or, can be included, and, it’s not being maintained and, it’s not needed –

  • It’s dangerous …

IMHO that is a bit exaggerated.

1 Like

Well, it is a bit too late now, but proper system management includes taking notes of what you change on the system. When you would have written down what extra software you installed (and what it pulled in), then you would have known what to remove when you later decided against using it.

And when still using it, it is something that will help you at the next fresh installation to let you install those packages soon after the installation has finished.

Pen and paper are not that outdated as many think. And you can of course also type it on an unrelated computer as notepad.

As it is now, a fresh installation will clean up things. Something I did every few new openSUSE versions, but now mostly only when new hardware is taken into use.

Sorry that I can not transfer my ease of mind to you, but I do not worry.

Eh? I would not consider documenting everything you do to your system proper system maintenance.

I would say the opposite, a properly maintained system shouldn’t require such documentation.

1 Like

It is a bout the changes, not about regular updates, etc.

But for me your situation illustrates the point. YMMV.