Orphan or not (optional deps)

Quick noob question: Will packages like git-lfs be marked explicitly installed when they originally were an “optional” package? So when they’re listed as orphan, I could remove them?

Little unsure here, because (*cough, cough*) at the beginning of my endeavour, I installed a very few packages using Pamac, and I seem to remember one of those said “needs git-lfs”.

Packages only needed at build time can/will be orphans afterwards, right?

Is there a command that lists installed optional dependencies?

To my knowledge, the optional dependencies, are optionally, intentionally and therefore explicitly installed and marked as such:

Example:

$ pacman -Qi gparted
Installed From : extra
Name : gparted
Version : 1.7.0-1
Description : A Partition Magic clone, frontend to GNU Parted
Architecture : x86_64
URL : https://gparted.org/
Licenses : GPL-2.0-or-later GFDL-1.2-or-later
Groups : None
Provides : None
Depends On : parted gtkmm3
Optional Deps : dosfstools: for FAT16 and FAT32 partitions [installed]
jfsutils: for jfs partitions [installed]
f2fs-tools: for Flash-Friendly File System [installed]
btrfs-progs: for btrfs partitions [installed]
exfatprogs: for exFAT partitions [installed]
ntfs-3g: for ntfs partitions
udftools: for UDF file system support
xfsprogs: for xfs partitions [installed]
nilfs-utils: for nilfs2 support [installed]
polkit: to run gparted from application menu [installed]
gpart: for recovering corrupt partition tables
mtools: utilities to access MS-DOS disks [installed]
xorg-xhost: authorization from wayland

$ pacman -Qi dosfstools

Name : dosfstools
Version : 4.2-5.1
Description : DOS filesystem utilities
Architecture : x86_64
URL : https://github.com/dosfstools/dosfstools
Licenses : GPL-3.0-or-later
Groups : None
Provides : None
Depends On : glibc
Optional Deps : None
Optional For : gparted grub libblockdev-fs udisks2
Conflicts With : None
Replaces : None
Installed Size : 437.22 KiB
Build Date : Sun 25 Aug 2024 03:39:08 PM CEST
Install Date : Sat 14 Dec 2024 01:48:24 PM CET
Install Reason : Explicitly installed
Install Script : No
Validated By : Signature

You could remove them without breaking the dependencies for the package they are optional for.
And they won’t be marked orphans if you remove the package for which they were optionally installed.

Thanks! Good you chose gparted so I could follow using the same. So -Qi is another one in my Pacman arsenal now. :wink:

For my git-lfs, I’m still unsure, ’cause my pacman -Qi git-lfs tells me

$ LANG=C pacman -Qi git-lfs
Name            : git-lfs
Version         : 3.6.1-1
Description     : Git extension for versioning large files
Architecture    : x86_64
URL             : https://git-lfs.github.com
Licenses        : MIT
Groups          : None
Provides        : None
Depends On      : git
Optional Deps   : None
Required By     : None
Optional For    : None
Conflicts With  : None
Replaces        : None
Installed Size  : 12,44 MiB
Packager        : Morten Linderud <foxboron@archlinux.org>
Build Date      : Mi 19 Feb 2025 20:00:43 CET
Install Date    : Mo 05 Mai 2025 20:35:01 CEST
Install Reason  : Installed as a dependency for another package
Install Script  : No
Validated By    : Signature

but not which package. At the same time, it’s listed as an orphan:

$ pacman -Qdt | grep git-lfs
git-lfs 3.6.1-1

This seems to be telling that it was a “required” dependency of a package, now removed (I guess only by passing -R and not -Rs to pacman) and therefore it is now there all by itself and not required by any other packages.

Ah, okay, good to know. It may well be (starting out with EOS) that I did use -R instead of -Rs or -Rns at one point in time.

And old apt guy starting to learn pacman mechanics—thanks again, your explanations are really helpful!

Time to start my own tldr pacman cheat sheet!

1 Like

Too bad I can’t mark two answers as solution, I’ll take the long one above. :slight_smile:

1 Like

Here is an excerpt from man pacman which can elucidate further pacman -Qdt and also pacman -Qdtt and the difference between the two:


-d, --deps
           Restrict or filter output to packages installed as dependencies. This option can be combined with -t for listing real orphans - packages that were installed as dependencies but are no longer required
           by any installed package.


-t, --unrequired
           Restrict or filter output to print only packages neither required nor optionally required by any currently installed package. Specify this option twice to include packages which are optionally, but not
           directly, required by another package.
1 Like

One more, if I may:

My orphan list is like this:

$ pacman -Qdt
asar 3.4.1-1
boost 1.88.0-2
cmake 4.0.2-1
dart 3.7.0-1
doxygen 1.13.2-1
git-lfs 3.6.1-1
gobject-introspection 1.84.0-1
gradle 8.13-1
itstool 1:2.0.7-3
meson 1.8.0-1
python-colorama 0.4.6-5
python-shtab 1.7.1-3
python-termcolor 2.5.0-1
qt5-tools 5.15.16+kde+r3-6
vala 0.56.18-2

Now I’m new, and of course unsure, so I tried this to see what actually would be removed, and the list is much longer. Would you consider it safe to remove all these?

$ pacman -Qdtq | pacman -Rsp -
vala-0.56.18-2
gtk-doc-1.34.0-3
python-pygments-2.19.1-1
python-lxml-5.4.0-1
glib2-docs-2.84.1-1
graphviz-12.2.1-1
gts-0.7.6.121130-3
netpbm-10.86.46-2
qt5-tools-5.15.16+kde+r3-6
python-termcolor-2.5.0-1
python-shtab-1.7.1-3
python-colorama-0.4.6-5
meson-1.8.0-1
python-tqdm-4.67.1-2
ninja-1.12.1-2
itstool-1:2.0.7-3
gradle-8.13-1
jdk21-openjdk-21.0.7.u6-1
libnet-2:1.3-1
java-runtime-common-3-6
java-environment-common-3-6
gobject-introspection-1.84.0-1
python-markdown-3.7-2
python-mako-1.3.10-1
python-markupsafe-2.1.5-3
git-lfs-3.6.1-1
doxygen-1.13.2-1
spdlog-1.15.3-1
fmt-11.1.4-1
clang-19.1.7-2
compiler-rt-19.1.7-1
dart-3.7.0-1
cmake-4.0.2-1
rhash-1.4.4-1
jsoncpp-1.9.6-3
cppdap-1.58.0-2
boost-1.88.0-2
asar-3.4.1-1
nodejs-23.9.0-1
simdjson-1:3.12.3-1
libngtcp2-1.12.0-1
c-ares-1.34.5-1

My gut feeling somehow says “Don’t—these are too many!”
(In case you wonder about the selection: I’m running Cinnamon.)

The first pacman command is giving you a list of the “real orphans”, that is
packages neither required nor optionally required by any currently installed packages.

Then you pipe its output into the second pacman which will remove them and their dependencies recursively.

In principle, it should be safe. If you want to take a more conservative approach, you can use the following function in your .bashrc:


rmorph() {
               while [[ $(pacman -Qdtq) ]]
               do     sudo pacman -R $(pacman -Qdtq)
               done
               }

So you basically remove the real orphans with the -R option until there is none left.

You could also check with pacman -Qqttd to see if there are any one package that may be optionally required by some other package and then if you want to keep it, mark it as explicitly installed.

1 Like

I’m not too faint-of-heart, help in this forum is fantastic, and this is a learning machine anyway, so I read a bit more and went the radical way:

  • Did a quick timeshift.
  • Did a yay -Yc (woo-hah! 1.9 GB freed, some palpitations…).
  • Did a yay—nothing unexpected.
  • Reboot. Cross my fingers!
  • All seems to work still, also tested a few applications.
  • Phew! (Wiping away sweat…)

I mean, what could have happened except me having to learn how to chroot back into it and repair it…? :laughing:

I really start loving this Endeavour(OS).

What I always do if I uninstall something is running the yay command you mentioned, just to be sure, think this would minimize the risk of messing something up.

1 Like

You can automate that using “paccache” with either a pacman hook or a systemd timer.

1 Like

Cheers, but… well… not yet. Still too anxious, I like to see and check what’ll happen still. And of course I have to memorize all these new pacman and yay commands, so typing them out for a while will be good for me. (Being an old man, see my profile :smile:)

In the past, I learned the hard way that to rely too much on automatisms, and becoming lazy, you forget (or never learn) the basics. Thus, if anything really goes wrong, you’re lost. Not so if you’ve learned and understood the underlying basics first. :wink:

1 Like

I don’t recommend removing orphans this way as it will remove optional dependencies of other packages.

It is better to use yay -Yc or paru -c.

2 Likes

Err…paccache doesn’t remove orphans, does it? It cleans the package cache.

Also, you should never automate the removal of orphans. That would be very risky.

1 Like

I try and “clean” EOS about once every 4-6 weeks, including orphan removal

UPDATE SYSTEM:
yay

UPDATE ARCH MIRRORS:
reflector --protocol https --verbose --latest 25 --sort rate | sudo tee /etc/pacman.d/mirrorlist

UPDATE EOS MIRRORS:
eos-rankmirrors --verbose

UPDATE SYSTEM:
yay -Syyu

CLEAN JOURNAL:
sudo journalctl --vacuum-time=4weeks

CLEAN CACHE (All Packages):
paccache -r

CLEAN CACHE (Uninstalled Packages):
paccache -ruk0

REMOVE ORPHANS:
yay -Yc

1 Like

Agreed. Not necessarily risky, because the Arch core usually has its dependencies sorted out, but it can lead to annoying results with user installed packages and esp. AUR packages.

Sometimes even a package was a dependency but you want to keep it and install it as non-dependency. I happens.

Usually I do something like paru -Qdtq | paru -Qi - and then everything is reviewed manually and uninstalled manually. If you do it every few months and don’t let it accumulate over years that only takes a few minutes.

Yeah now that you mentioned it I was a bit off, I was talking about cached packages, not orphans. I blame it on multi-tasking :wink: I have an alias for cleaning up orphans which I run once in a while and then check what it removes.

1 Like

Removing meta packages can cause serious havoc when removing orphans automatically. Consider the situation where someone removes plasma-meta or base. The system will work fine when removing those packages. However, if they don’t review the package list when removing orphans, bad things can happen.

Cool. So I did—unknowingly—the right thing, using yay -Yc.

Thanks all others that chimed in for even more explanations!

1 Like