**Never mind, I did find a solution! *zypper remove --clean-deps ***Hello. I installed k3b, but then changed my mind and removed it via Yast. However, I notice that it only removed k3b itself, and not the whack of dependencies that came with it. So, is there a way to remove all the clutter, similar to Debian’s apt autoremove? I did do a quick search on this, and found the exact same question **nine years ago **(see here). Hopefully some progress has been made on this issue.
Hmm. My ten minutes are up. Anyway, I discovered that what I thought was a solution – specifically, what I thought was an equivalent to Debian’s apt autoremove – really isn’t. I ran the command “zypper remove --clean-deps” and it demanded a package name. So… I then typed “k3b” as the package name, and it complained that k3b isn’t installed (I had removed it previously). So, to clean up the junk that the removal of k3b left behind, I had to reinstall it and then remove it once again with the “–clean-deps” tag. You’d think after nine years there’d be a way to do this on demand. Well, I guess I’ll just have to remember to always flag any removal with “–clean-deps”. Is there an equivalent to this flag in Yast? Or should I stick to zypper when removing programs?
Your claim is unsupported by evidence. ‘zypper remove’ does remove dependencies unless needed by other packages still installed:
**erlangen:~ #** zypper remove --dry-run k3b
Reading installed packages...
Resolving package dependencies...
The following 2 packages are going to be REMOVED:
k3b k3b-lang
2 packages to remove.
After the operation, 30.2 MiB will be freed.
**Continue? [y/n/v/...? shows all options] (y): **
**erlangen:~ #**
So, is there a way to remove all the clutter, similar to Debian’s apt autoremove? I did do a quick search on this, and found the exact same question **nine years ago **(see here). Hopefully some progress has been made on this issue.
Packages subcommand allows to query:
**erlangen:~ #** zypper packages --help
packages (pa) [OPTIONS] [REPOSITORY] ...
List all packages available in specified repositories.
Command options:
--orphaned Show packages which are orphaned (without repository). Default: false
--suggested Show packages which are suggested. Default: false
--recommended Show packages which are recommended. Default: false
--unneeded Show packages which are unneeded. Default: false
.....
**erlangen:~ #**
Example:
**erlangen:~ #** zypper packages --orphaned | grep @System | cut -d '|' -f3 | xargs echo zypper rm
zypper rm aocl-linux-aocc aocl-linux-gcc boost-license1_66_0 crazydiskmark hd-idle libboost_filesystem1_66_0 libboost_program_options1_66_0 libboost_system1_66_0 libdvdcss2 libgdal27 stacer
**erlangen:~ #**
If you do not understand the claim, nothing helps.
‘zypper remove’ does remove dependencies unless needed by other packages still installed
Zypper removes packages that require package you remove. If additional packages to be removed are required by some other packages then zypper will **remove **these other packages as well, so there is no “unless”.
Packages that are left after package removal by definition do not require package that was removed.
“needed” is entirely meaningless when talking about RPM which has at least 4 different ways how one package may “need” another.
In YaST change View to Package Classification, there are “Unneeded Packages”. This is global, you cannot ask for “packages that were installed when you installed k3b”. Actually I do not think zypper manual is accurate either. The --clean-deps flag has no way to determine “which packages become unneeded after removal of requested packages”. It can only “check for unneeded packages” after removal. Which means that if you perform “zypper remove foo” followed by “zypper remove --clean-deps bar”, then both packages that became unneeded after removal of “bar” and “foo” will be removed.
zypper works more straight forward:
**erlangen:~ #** grep cleandeps /etc/zypp/zypp.conf
# solver.**cleandeps**OnRemove = false
**erlangen:~ #**
## EXPERTS ONLY: Cleanup when deleting packages. Whether the solver should
## per default try to remove packages exclusively required by the ones he's
## asked to delete.
##
## This option should be used on a case by case basis, enabled via
## command line options or switches the applications offer. Changing
## the global default on a system where unattended actions are performed,
## may easily damage your system.
##
## CHANGING THE DEFAULT IS NOT RECOMMENDED.
##
## Valid values: boolean
## Default value: false
##
# solver.cleandepsOnRemove = false
Yet another switch:
3400G:~ # zypper install --dry-run k3b
Loading repository data...
Reading installed packages...
Resolving package dependencies...
The following 22 NEW packages are going to be installed:
cdrdao cdrecord k3b k3b-lang libFLAC++6 libaudiofile1 libedc_ecc1_0 libedc_ecc_dec1_0 libfaac0 libiso9660-11 libmpeg2convert0 libmusicbrainz4 libopencore-amrnb0 libopencore-amrwb0 libopusfile0 libsox3 libvcdinfo0 normalize readcd sox transcode vcdimager
The following 5 recommended packages were automatically selected:
k3b-lang normalize sox transcode vcdimager
22 new packages to install.
Overall download size: 14.8 MiB. Already cached: 0 B. After the operation, additional 41.9 MiB will be used.
Continue? [y/n/v/...? shows all options] (y):
3400G:~ #
vs.
3400G:~ # zypper install --dry-run **--no-recommends** k3b
Loading repository data...
Reading installed packages...
Resolving package dependencies...
The following 9 NEW packages are going to be installed:
cdrdao cdrecord k3b k3b-lang libFLAC++6 libedc_ecc1_0 libedc_ecc_dec1_0 libmusicbrainz4 readcd
9 new packages to install.
Overall download size: 12.0 MiB. Already cached: 0 B. After the operation, additional 32.5 MiB will be used.
Continue? [y/n/v/...? shows all options] (y):
3400G:~ #
See also /etc/zypp/zypper.conf
## Install soft dependencies (recommended packages)
##
## CAUTION: The system wide default for all libzypp based applications (zypper,
## yast, pk,..) is defined in /etc/zypp/zypp.conf(solver.onlyRequires) and it
## will per default install recommended packages. It is NOT RECOMMENDED to define
## this value here for zypper exclusively, unless you are very certain that you
## want zypper to behave different than other libzypp based packagemanagement software
## on your system.
##
## Valid values: boolean
## Default value: follow zypp.conf(solver.onlyRequires)
##
# installRecommends = yes
Hello,
AFAIK an orphaned package is a package who it is not available form any enabled repositories.
I think that OP want to know how to remove packages installed as dependencies from a removed package.
Here you will find a clear explanation (the difference between unneeded packages and clean-deps):
https://github.com/openSUSE/libsolv/blob/master/src/cleandeps.c
Beware of bugs in the above code; I have only proved it correct, not tried it.(Awesome Knuth Quote On Code Proofs | You’ve Been Haacked). Predicting what will happen is lengthy. Trying is easy and can be easily undone.
Thanks karl, your command suggestions are much appreciated. I did check out the options in Yast2 Software management tool, and I notice that it does include an option, when removing a package, of “cleanup when deleting packages”. So, that’s something anyway. Anyway, it does seem that there’s nothing quite as straight forward as Debian’s apt autoremove, but that’s fine. It just means I’ll have to remember to include the cleanup option when I am actually removing a package.
To reminisce about when I used Debian Sarge (long time ago), I recall then that the option of apt autoremove did not exist. Instead, there were early attempts, like, I think, deborphan or something. I would try these early tools to clean up all the cruft, and yikes, often half the system would be cleaned along with it.
IMHO it is not 100% clear what to do in such situations. Nevertheless people press that something should be done because they think it is obvious how to solve it. The result is something that satisfies nobody.
And yes, an orphaned package in YaST/zypper is a package that is not available in any of the active repositories on a system. So that can e.g. be the case when you install a package and then disable the repo where it is installed from (because you do not want other packages that might be on that repo). So something you have done on purpose and thus such an orphan is not a bad thing by definition. Same I guess for a package that is installed directly not coming from a repo.
- ‘zypper install’ implies ‘–recommends’ and installs recommended packages too.
- There is no obvious way to undo the installation of recommended packages.
- Manually deinstall recommended packages based on /var/log/zypp/history. Alternatively use tee to save a list of installed packages.
- An inadvertent “zypper remove” will leave stale dependencies. This is easily fixed be reinstalling and running ‘zypper remove --clean-deps’.
Basically I am satisfied.
BTW: I deliberately removed several packages. Running ‘zypper install-new-recommends’ will reinstall them:
3400G:~ # zypper install-new-recommends --dry-run
Loading repository data...
Reading installed packages...
Resolving package dependencies...
The following 18 NEW packages are going to be installed:
avahi avahi-lang libavahi-core7 libdaemon0 libply-boot-client5 libply-splash-core5 libply-splash-graphics5 libply5 nss-mdns plymouth plymouth-branding-openSUSE plymouth-dracut plymouth-plugin-label plymouth-plugin-two-step plymouth-scripts plymouth-theme-bgrt
plymouth-theme-spinner xf86-video-ati
18 new packages to install.
Overall download size: 1.4 MiB. Already cached: 0 B. After the operation, additional 2.8 MiB will be used.
Continue? [y/n/v/...? shows all options] (y):
3400G:~ #
You can use
zypper pa --unnedeed
to find packages that are no longer needed by other installed packages (patterns).
Did you ever do that and inspect the results?
I just show one out of that list on my system:
| Main (OSS) | dolphin | 20.04.2-lp152.1.1 | x86_64
Dolphin may be “no longer needed by other installed packages (patterns)”, but I need it very much. So what is the value of this?
Hello,
It seems that zypper sometimes acts strange.
I am sure that you do need dolphin.
I tried it:
:~ # zypper pa --unneeded
Loading repository data...
Reading installed packages...
No packages found.
From zypper manual
https://en.opensuse.org/SDB:Zypper_manual_(plain)
packages (pa) [options] [repository]...
List all available packages or all packages from specified repositories. Similar to zypper search -s -t
package.
-r, --repo alias|name|#|URI
Just another means to specify repositories.
-i, --installed-only
Show only installed packages.
-u, --not-installed-only
Show only packages which are not installed. + The old option name --uninstalled-only is still
acceptable, but should be considered deprecated.
--orphaned
Show packages which are orphaned (without repository).
--suggested
Show packages which are suggested.
--recommended
Show packages which are recommended.
**--unneeded
Show packages which are unneeded.**
And this is a answer from a person who knows about openSUSE more (better) than me:
https://www.reddit.com/r/openSUSE/comments/f5pjge/how_to_you_clean_up_unused_packages_over_time/
Installed patterns consist of required and recommended packages:
erlangen:~ # zypper info --requires --type pattern kde_plasma
Loading repository data...
Reading installed packages...
Information for pattern kde_plasma:
-----------------------------------
Repository : openSUSE-Tumbleweed-Oss
Name : kde_plasma
Version : 20181130-5.1
Arch : noarch
Vendor : openSUSE
Installed : Yes (automatically)
Visible to User : Yes
Summary : KDE Plasma 5 Desktop Base
Description :
Base packages for the KDE Plasma 5 desktop environment.
Requires : patterns-kde-kde_plasma = 20181130-5.1
Contents :
S | Name | Type | Dependency
---+------------------------------+---------+------------
i | breeze5-cursors | package | Required
i | breeze5-decoration | package | Required
i | breeze5-icons | package | Required
i | breeze5-style | package | Required
i | desktop-data-openSUSE | package | Required
i+ | patterns-base-x11 | package | Required
i | patterns-kde-kde_plasma | package | Required
i | plasma5-session | package | Required
i | polkit-default-privs | package | Required
i | xdg-user-dirs | package | Required
i | alsa-plugins-pulse | package | Recommended
i | baloo5-file | package | Recommended
i | baloo5-kioslaves | package | Recommended
i | baloo5-tools | package | Recommended
i | bluedevil5 | package | Recommended
i+ | breeze5-wallpapers | package | Recommended
i | dolphin | package | Recommended
i | ffmpegthumbs | package | Recommended
i | kde-print-manager | package | Recommended
i | kdegraphics-thumbnailers | package | Recommended
i | kdenetwork-filesharing | package | Recommended
i | kgamma5 | package | Recommended
i | khelpcenter5 | package | Recommended
i | kio-extras5 | package | Recommended
i | kwalletmanager5 | package | Recommended
i | kwrited5 | package | Recommended
i | phonon4qt5-backend-gstreamer | package | Recommended
i | pinentry-qt5 | package | Recommended
i | plasma-nm5 | package | Recommended
i | plasma5-addons | package | Recommended
i | plasma5-disks | package | Recommended
i | plasma5-pa | package | Recommended
i | plasma5-pk-updates | package | Recommended
i | plasma5-session-wayland | package | Recommended
i | plasma5-thunderbolt | package | Recommended
i | pulseaudio | package | Recommended
i | pulseaudio-module-x11 | package | Recommended
i | pulseaudio-module-zeroconf | package | Recommended
i | pulseaudio-utils | package | Recommended
i+ | sddm | package | Recommended
erlangen:~ #
Check repo Packman for unneeded packages:
erlangen:~ # zypper packages --unneeded --repo Packman
Loading repository data...
Reading installed packages...
S | Repository | Name | Version | Arch
--+------------+------------------------------+------------+-------
i | Packman | libgstadaptivedemux-1_0-0 | 1.18.1-4.2 | x86_64
i | Packman | libgstbadaudio-1_0-0 | 1.18.1-4.2 | x86_64
i | Packman | libgstbasecamerabinsrc-1_0-0 | 1.18.1-4.2 | x86_64
i | Packman | libgstcodecparsers-1_0-0 | 1.18.1-4.2 | x86_64
i | Packman | libgstisoff-1_0-0 | 1.18.1-4.2 | x86_64
i | Packman | libgstmpegts-1_0-0 | 1.18.1-4.2 | x86_64
i | Packman | libgstsctp-1_0-0 | 1.18.1-4.2 | x86_64
i | Packman | libgstwayland-1_0-0 | 1.18.1-4.2 | x86_64
i | Packman | libgstwebrtc-1_0-0 | 1.18.1-4.2 | x86_64
erlangen:~ #
Delete them:
erlangen:~ # zypper packages --unneeded --repo Packman |grep Packman|cut -d '|' -f 3|xargs zypper remove --clean-deps
Reading installed packages...
Resolving package dependencies...
The following 10 packages are going to be REMOVED:
libgstadaptivedemux-1_0-0 libgstbadaudio-1_0-0 libgstbasecamerabinsrc-1_0-0 libgstcodecparsers-1_0-0 libgstisoff-1_0-0 libgstmpegts-1_0-0 libgstsctp-1_0-0 libgsturidownloader-1_0-0 libgstwayland-1_0-0 libgstwebrtc-1_0-0
10 packages to remove.
After the operation, 1007.5 KiB will be freed.
Continue? [y/n/v/...? shows all options] (y): y
( 1/10) Removing libgstadaptivedemux-1_0-0-1.18.1-4.2.x86_64 ..................................................................................................................................................................................................................................[done]
( 2/10) Removing libgstbadaudio-1_0-0-1.18.1-4.2.x86_64 .......................................................................................................................................................................................................................................[done]
( 3/10) Removing libgstbasecamerabinsrc-1_0-0-1.18.1-4.2.x86_64 ...............................................................................................................................................................................................................................[done]
( 4/10) Removing libgstcodecparsers-1_0-0-1.18.1-4.2.x86_64 ...................................................................................................................................................................................................................................[done]
( 5/10) Removing libgstisoff-1_0-0-1.18.1-4.2.x86_64 ..........................................................................................................................................................................................................................................[done]
( 6/10) Removing libgstmpegts-1_0-0-1.18.1-4.2.x86_64 .........................................................................................................................................................................................................................................[done]
( 7/10) Removing libgstsctp-1_0-0-1.18.1-4.2.x86_64 ...........................................................................................................................................................................................................................................[done]
( 8/10) Removing libgstwayland-1_0-0-1.18.1-4.2.x86_64 ........................................................................................................................................................................................................................................[done]
( 9/10) Removing libgstwebrtc-1_0-0-1.18.1-4.2.x86_64 .........................................................................................................................................................................................................................................[done]
(10/10) Removing libgsturidownloader-1_0-0-1.18.1-4.2.x86_64 ..................................................................................................................................................................................................................................[done]
There are running programs which still use files and libraries deleted or updated by recent upgrades. They should be restarted to benefit from the latest updates. Run 'zypper ps -s' to list these programs.
erlangen:~ #
Note: There are only needed packages now:
erlangen:~ # zypper packages --unneeded
Loading repository data...
Reading installed packages...
No packages found.
erlangen:~ #
e.g. this one:
erlangen:~ # zypper if dolphin
Loading repository data...
Reading installed packages...
Information for package dolphin:
--------------------------------
Repository : openSUSE-Tumbleweed-Oss
Name : dolphin
Version : 20.08.3-1.1
Arch : x86_64
Vendor : openSUSE
Installed Size : 1.5 MiB
Installed : Yes (automatically)
Status : up-to-date
Source package : dolphin-20.08.3-1.1.src
Summary : KDE File Manager
Description :
This package contains the default file manager of KDE Workspaces.
erlangen:~ #
And that is exactly what this is about. A package that may be unneeded by pure technical reasons (not needed by any package) may still be needed by the person that manages the system. There is no reason for a system to decide that e.g. VLC is needed, but it is there because the users need it. As zypper (or any other higher level tool for any other way of managing software on any type of system, Linux or not) can only inform you about pure technical connections, it can not remove from this list those packages that happen to be on the top of a dependency tree, but that “you need”. That is IMHO a very basic thing that makes any try to solve the “unneeded packages” case fruitless.
@hcvv, you are right.
How I see that problem:
with
zypper pa --unneeded
you will find packages that are not needed by another package or pattern. So, after that command, an user must decide what package(s) he need. Only the user can decide that, not zypper (I think that is the reason because there is no command “zypper rm --unneeded” only “zypper pa --unneeded”).
“unneeeded” means packages not needed by another package (pattern) not by the user.
I think that is the way zypper want to help us to find that packages. I do not know an easiest way to find that kind of packages.
About the dolphin issue:
I did not use KDE so I cannot check my guess.
I think that dolphin depends only by “pattern kde”. So, if you did not have installed that pattern, dolphin is no needed by another package (pattern) and zypper it mark it “unneeded”.
If I am right, zypper did not acted strange.
I agree with you. All those commands are commands to help you in finding out what you want to know, depending on what you want to know. No magic (as always with computers and software).
And of course, words like “orphaned” and “unneeded” should not lure you in giving them a meaning that fits your own ideas about what they should mean. They probably mean something different and only through reading documentation (man pages, etc.) and even try and error you may find out what it means for this particular application.
I only took Dolphin as an easy example. In my list there were more of those that I use daily and what is in there is very dependent on what you installed for your type of usage.
And this can go even more tricky. What about a library that is not needed by any other package (and thus will be in such a list), but that is used by a program installed by copy, or building, or made by a developer on the system?
Yep.
- Zypper builds the list of needed packages as follows:
-
Upon initial install a few patterns are installed explicitly, e.g.: base, kde, x11, yast2_basis, …
-
Dependent packages ‘required’ or ‘recommended’ by the patterns are added recursively: Installed: Yes (automatically)
-
Upon running ‘zypper install …’ new packages (Installed: Yes
) and their dependencies are added to the list.
- The command ‘zypper packages --unneeded’ lists installed packages which are not in the list. They can be safely deleted by running:
zypper packages --unneeded |grep ^i|cut -d '|' -f 3|xargs zypper remove --clean-deps
- If the list of unneeded packages contains a package which should be kept remove it from the list by:
-
aborting zypper
-
running a forced install
-
rerunning ‘zypper packages --unneeded …’.
3400G:~ # zypper packages --unneeded
Loading repository data...
Reading installed packages...
No packages found.
3400G:~ #
Have a lot of fun …