Correct process for viewing and removing oprhans in EOS Gnome?

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/

Ex. https://archlinux.org/packages/community/x86_64/nemo-python/

Dependencies (16)

Required By (7)

I am also interested if someone knows how to list all the packages which have a certain package X as optional dependence. If that is possible at all.

It would be more clear, if you gave a specific example, and the reason of usage.

You may try what -Qttd serves for.

I go a different way to get rid of unnecessary dependencies with Yay. But we can compare it.

Temporarily switch terminal output to English

LANG=c

13:45:00^jag@jag-81vr:
~> pacman -Qdt
botan 3.0.0-1
openssl-1.1 1.1.1.t-1
14:23:12^jag@jag-81vr:
~> yay -Qdt
botan 3.0.0-1
openssl-1.1 1.1.1.t-1
14:48:34^jag@jag-81vr:
~> yay -Yc
[sudo] password for jag: 
checking dependencies...

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
15:00:58^jag@jag-81vr:

When I now do the cross check I find that

yay -Yc

works correctly.

14:47:10^jag@jag-81vr:
~> yay -Sii botan 3.0.0-1 | grep Provides
Provides        : None
14:47:43^jag@jag-81vr:
~> yay -Sii openssl-1.1 1.1.1.t-1 | grep Provides
Provides        : libcrypto.so=1.1-64  libssl.so=1.1-64
14:48:34^jag@jag-81vr:

But I like to be taught better. :thinking:

Suppose you have a package X installed in your system and you want to know what other packages might have X as optional dependency.

My question: is there any command to run that list all the packages that have X as optional dependency?

For example ntfs-3g is optional dependency for gparted. Is there any command to run on ntfs-3g which would then output gparted (plus possibly others that might have it as optional dependency)

Of course sudo pacman -R ntfs-3g would tell me exactly that:

 sudo pacman -R ntfs-3g 
checking dependencies...
:: gparted optionally requires ntfs-3g: for ntfs partitions
:: udisks2 optionally requires ntfs-3g: NTFS filesystem management support

But I thought if there was something with -Q which could query pacman.

So that?

~> pacman -Qii ntfs-3g | grep Optional
Optional Deps   : None
Optional For    : gparted  udisks2
15:26:16^jag@jag-81vr:

1 Like

Sure! That works. Thanks!

Looks like with just one -i you will get the same output:

$ pacman -Qi ntfs-3g | grep Opt
Optional Deps   : None
Optional For    : gparted  udisks2

What is the second -i for?

i=information
ii=more information/extensive output
But I think we are getting offtopic. :laughing:

1 Like

Thanks!

Sort of…happens easy around here :blush:

1 Like

:point_up_2: :person_shrugging:

If you are examining the impact of Removing the package, you need this:

LANG=C pacman -Qi ntfs-3g | grep -E "^Required By|^Optional For"

Reason for the usage of the command line?

General curiosity/ Gaining knowledge and the like. :slightly_smiling_face:

So nothing with only pacman -Qblabla “package”. It has to be piped through grep etc.

Thanks so much!

1 Like

For the “required by” packages (not the optional ones), you can use pactree :

pactree -r ntfs-3g
1 Like

Yes, thanks!

This will show all packages that are dependent on ntfs-3g but as you mention not those which are "optionally dependent.

I thought if there might have been a pacman -Q plus some other flags for showing them without piping and stuff.

That’s what I missed years ago coming from Debian to Manjaro, other package managers bring a bit more in some situations.

https://wiki.archlinux.org/title/Pacman/Rosetta#Querying_package_dependencies

2 Likes

In comparison to dnf, there indeed are quite a few shortcomings of pacman. :wink:

I suppose each one that finds this lack of feature in pacman has already posted upstream such a feature request and rejected :joy: .

I think this feature is potentially useful. You should ask pacman devs to add it :person_shrugging: .

1 Like

Thank you all for good inputs and advises !

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’.

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.