Please inform if this is correct process for viewing and removing orphaned packages in EOS:
1.) pacman -Qdt = To see the list of orphaned packages.
2.) sudo pacman -Rs $(pacman -Qdtq) = To remove all the orphans. But this command removes also packages which maybe are used seldom, but nevertheless are still necessary packages for some other packages.
In order to avoid removing still necessary packages indicated by this command by name run at first instead following command:
3.) sudo pacman -D --asexplicit package1 package2 = To mark some packages not to be removed now.
4.) After running the command in 3.) it is OK to run command in 2.) sudo pacman -Rs $(pacman -Qdtq), because now the appointed packages (package1 package 2) which are still in use will not be removed.
– s, --recursive
Remove each target specified including all of their dependencies, provided that
(A) they are not required by other packages; and (B) they were not explicitly installed by the user.
This operation is recursive and analogous to a backwards --sync operation, and it helps keep a clean system without orphans. If you want to omit condition (B), pass this option twice.
So I think pacman -Rs $(pacman -Qdtq) will not remove any packages that
That is, if they are “hard” dependencies of other packages. In this case they shouldn’t even show as orphans.
But I think it would remove them if they are “optional” dependencies of some other packages.
It is good then to review pacman -Qqtd and check if some packages are optional for something else and decide for your self if you want to keep them or not.
If there is a command to check what other packages have the package X as optional dependency, I am not aware of it. However it is possible to check it up here: https://archlinux.org/packages/
I go a different way to get rid of unnecessary dependencies with Yay. But we can compare it.
Temporarily switch terminal output to English
~> pacman -Qdt
~> yay -Qdt
~> yay -Yc
[sudo] password for jag:
Package (1) Old Version Net Change
botan 3.0.0-1 -8.26 MiB
Total Removed Size: 8.26 MiB
:: Do you want to remove these packages? [Y/n] n
-> exit status 1
As a result of this I will make a following change into my original process: after command sudo pacman -Rs $(pacman -Qdtq) I will add into my process command LANG=C pacman -Qi packageX | grep -E "^Required By|^Optional For" for additional checking if packageX is required or optional. All the rest can remain as in the original process plan. OK ?
In case of no objections I’ll mark this thread as ‘Solution’.