How to exclude optional deps on a `pacman -Rns`?

I want to unclutter my system a little, and remove quickemu, since it currently doesn’t work anyway. Now Pacman shows me some optional dependencies which I don’t want to remove. Is there a way to do that apart from removing and reinstalling?

$ sudo LANG=C pacman -Rns quickemu 
[sudo] Passwort für matthias: 
checking dependencies...
:: clutter-gst optionally requires gst-plugins-good: Video camera capture
:: dracut optionally requires multipath-tools: dmraid dracut module support
:: dracut optionally requires ndctl: NVDIMM support
:: file-roller optionally requires cdrtools: ISO image support
:: libwbclient optionally requires glusterfs: for vfs_glusterfs support
:: smbclient optionally requires glusterfs: for vfs_glusterfs support
:: webkit2gtk optionally requires gst-plugins-good: media decoding
:: webkit2gtk-4.1 optionally requires gst-plugins-good: media decoding
:: webkitgtk-6.0 optionally requires gst-plugins-good: media decoding

Package (125)                            Old Version    Net Change 

brltty                                   6.7-5            -9,54 MiB
capstone                                 5.0.6-1         -14,33 MiB
cdrtools                                 3.02a09-6        -3,87 MiB
dtc                                      1.7.2-4          -0,56 MiB
edk2-aarch64                             202411-1       -130,00 MiB
edk2-arm                                 202411-1       -130,00 MiB
edk2-ovmf                                202411-1        -27,05 MiB
gfxstream                                0.1.2-2          -5,47 MiB
glm                                      1.0.1-1         -20,34 MiB
glusterfs                                1:11.1-5        -17,37 MiB
gst-plugins-good                         1.26.2-2         -7,19 MiB
imlib2                                   1.12.5-1         -1,47 MiB
iniparser                                4.2.6-1          -0,06 MiB
jq                                       1.8.0-1          -0,44 MiB
libaemu                                  0.1.2-5          -1,31 MiB
libcaca                                  0.99.beta20-5    -2,68 MiB
libcacard                                2.8.1-1          -0,11 MiB
libiscsi                                 1.20.0-2         -0,41 MiB
liblouis                                 3.34.0-1        -12,88 MiB
libshout                                 1:2.4.6-5        -0,20 MiB
libslirp                                 4.9.1-1          -0,16 MiB
libtpms                                  0.10.1-1         -1,06 MiB
libtraceevent                            1:1.8.4-1        -0,39 MiB
libtracefs                               1.8.2-1          -0,38 MiB
libxdp                                   1.5.5-1          -0,18 MiB
multipath-tools                          0.11.0-1         -1,20 MiB
ndctl                                    79-1             -0,94 MiB
oniguruma                                6.9.10-1         -0,88 MiB
phodav                                   3.0-4            -0,22 MiB
qemu-audio-alsa                          10.0.0-7         -0,07 MiB
qemu-audio-dbus                          10.0.0-7         -0,30 MiB
qemu-audio-jack                          10.0.0-7         -0,07 MiB
qemu-audio-oss                           10.0.0-7         -0,07 MiB
qemu-audio-pa                            10.0.0-7         -0,07 MiB
qemu-audio-pipewire                      10.0.0-7         -0,09 MiB
qemu-audio-sdl                           10.0.0-7         -0,06 MiB
qemu-audio-spice                         10.0.0-7         -0,06 MiB
qemu-base                                10.0.0-7         -0,05 MiB
qemu-block-curl                          10.0.0-7         -0,08 MiB
qemu-block-dmg                           10.0.0-7         -0,06 MiB
qemu-block-gluster                       10.0.0-7         -0,08 MiB
qemu-block-iscsi                         10.0.0-7         -0,09 MiB
qemu-block-nfs                           10.0.0-7         -0,07 MiB
qemu-block-ssh                           10.0.0-7         -0,09 MiB
qemu-chardev-baum                        10.0.0-7         -0,07 MiB
qemu-chardev-spice                       10.0.0-7         -0,07 MiB
qemu-common                              10.0.0-7         -4,44 MiB
qemu-desktop                             10.0.0-7         -0,05 MiB
qemu-docs                                10.0.0-7        -18,47 MiB
qemu-emulators-full                      10.0.0-7         -0,05 MiB
qemu-full                                10.0.0-7         -0,05 MiB
qemu-hw-display-qxl                      10.0.0-7         -0,14 MiB
qemu-hw-display-virtio-gpu               10.0.0-7         -0,12 MiB
qemu-hw-display-virtio-gpu-gl            10.0.0-7         -0,09 MiB
qemu-hw-display-virtio-gpu-pci           10.0.0-7         -0,06 MiB
qemu-hw-display-virtio-gpu-pci-gl        10.0.0-7         -0,06 MiB
qemu-hw-display-virtio-gpu-pci-rutabaga  10.0.0-7         -0,06 MiB
qemu-hw-display-virtio-gpu-rutabaga      10.0.0-7         -0,09 MiB
qemu-hw-display-virtio-vga               10.0.0-7         -0,06 MiB
qemu-hw-display-virtio-vga-gl            10.0.0-7         -0,06 MiB
qemu-hw-display-virtio-vga-rutabaga      10.0.0-7         -0,06 MiB
qemu-hw-s390x-virtio-gpu-ccw             10.0.0-7         -0,06 MiB
qemu-hw-uefi-vars                        10.0.0-7         -0,11 MiB
qemu-hw-usb-host                         10.0.0-7         -0,10 MiB
qemu-hw-usb-redirect                     10.0.0-7         -0,11 MiB
qemu-hw-usb-smartcard                    10.0.0-7         -0,08 MiB
qemu-img                                 10.0.0-7        -10,56 MiB
qemu-pr-helper                           10.0.0-7         -1,05 MiB
qemu-system-aarch64                      10.0.0-7        -29,82 MiB
qemu-system-alpha                        10.0.0-7        -11,42 MiB
qemu-system-alpha-firmware               10.0.0-7         -0,20 MiB
qemu-system-arm                          10.0.0-7        -27,22 MiB
qemu-system-arm-firmware                 10.0.0-7         -0,05 MiB
qemu-system-avr                          10.0.0-7         -7,48 MiB
qemu-system-hppa                         10.0.0-7        -11,51 MiB
qemu-system-hppa-firmware                10.0.0-7         -0,40 MiB
qemu-system-loongarch64                  10.0.0-7        -13,49 MiB
qemu-system-m68k                         10.0.0-7         -9,02 MiB
qemu-system-microblaze                   10.0.0-7        -15,54 MiB
qemu-system-microblaze-firmware          10.0.0-7         -0,07 MiB
qemu-system-mips                         10.0.0-7        -52,79 MiB
qemu-system-or1k                         10.0.0-7        -11,23 MiB
qemu-system-ppc                          10.0.0-7        -30,26 MiB
qemu-system-ppc-firmware                 10.0.0-7         -5,18 MiB
qemu-system-riscv                        10.0.0-7        -29,14 MiB
qemu-system-riscv-firmware               10.0.0-7         -0,56 MiB
qemu-system-rx                           10.0.0-7         -7,52 MiB
qemu-system-s390x                        10.0.0-7        -11,40 MiB
qemu-system-s390x-firmware               10.0.0-7         -0,14 MiB
qemu-system-sh4                          10.0.0-7        -22,82 MiB
qemu-system-sparc                        10.0.0-7        -19,80 MiB
qemu-system-sparc-firmware               10.0.0-7         -1,93 MiB
qemu-system-tricore                      10.0.0-7         -7,72 MiB
qemu-system-x86                          10.0.0-7        -50,20 MiB
qemu-system-x86-firmware                 10.0.0-7         -0,12 MiB
qemu-system-xtensa                       10.0.0-7        -28,67 MiB
qemu-tests                               10.0.0-7         -0,44 MiB
qemu-tools                               10.0.0-7         -2,27 MiB
qemu-ui-curses                           10.0.0-7         -0,09 MiB
qemu-ui-dbus                             10.0.0-7         -0,34 MiB
qemu-ui-egl-headless                     10.0.0-7         -0,06 MiB
qemu-ui-gtk                              10.0.0-7         -0,12 MiB
qemu-ui-opengl                           10.0.0-7         -0,08 MiB
qemu-ui-sdl                              10.0.0-7         -0,09 MiB
qemu-ui-spice-app                        10.0.0-7         -0,06 MiB
qemu-ui-spice-core                       10.0.0-7         -0,11 MiB
qemu-user                                10.0.0-7       -104,09 MiB
qemu-vhost-user-gpu                      10.0.0-7         -0,80 MiB
qemu-vmsr-helper                         10.0.0-7         -1,03 MiB
rutabaga-ffi                             0.1.6-2          -2,36 MiB
sdl2_image                               2.8.8-1          -0,20 MiB
seabios                                  1.16.3-1         -1,04 MiB
socat                                    1.8.0.3-1        -0,52 MiB
spice                                    0.16.0-1         -1,12 MiB
spice-gtk                                0.42-4           -3,02 MiB
spice-protocol                           0.14.5-1         -0,09 MiB
swtpm                                    0.10.1-1         -1,24 MiB
taglib                                   2.1-1            -1,97 MiB
usbredir                                 0.15.0-1         -0,14 MiB
vde2                                     2.3.3-6          -0,69 MiB
virglrenderer                            1.1.1-1          -1,25 MiB
virtiofsd                                1.13.1-1         -2,53 MiB
wolfssl                                  5.8.0-1          -4,00 MiB
zsync                                    0.6.2-5          -0,20 MiB
quickemu                                 4.9.7-1          -0,24 MiB

Total Removed Size:  963,98 MiB

:: Do you want to remove these packages? [Y/n] 

I want to keep:

gst-plugins-good
multipath-tools
ndctl
cdrtools
glusterfs
jq
iniparser
libshout
taglib

Don’t use -Rs if you care about optional deps. It is a side effect of that.

Instead, you can occasionally clear orphans with yay -Yc or paru -c.

As a side note, are you sure you want to use -Rn? It doesn’t do what most people think it does. It inhibits the creation of .pacsave files. Those files are only created on a small number of system-wide configs and only if you have modified those config files.

I thought -Rn would remove saved (changed) config data, looks like what you explain (much better).

quickemu has so many deps, that’s why I thought using -Rs would be good, since I’d manually surely overlook some.

Is there maybe a way I could write what Pacman thinks it should remove to a file, then edit that to exclude those I want to keep, and feed it back to Pacman for final removal? I mean, kinda like we do when removing orphans?

That seems like a lot more work than sudo pacman -R quickemu && yay -Yc

So a yay -Yc would only remove real orphans and not optional deps?

Yes, it should.

It easy enough to check. Remove quickemu and then run yay -Yc and see what it wants to remove.

Perfect, I’ll try, thanks a bundle! Love learning from you, you have a very helpful way of explaining things.

1 Like

Tried that, but yay -Yc still wants to remove the optional deps:

$ LANG=C yay -Yc
checking dependencies...
:: clutter-gst optionally requires gst-plugins-good: Video camera capture
:: dracut optionally requires multipath-tools: dmraid dracut module support
:: dracut optionally requires ndctl: NVDIMM support
:: libwbclient optionally requires glusterfs: for vfs_glusterfs support
:: smbclient optionally requires glusterfs: for vfs_glusterfs support
:: webkit2gtk optionally requires gst-plugins-good: media decoding
:: webkit2gtk-4.1 optionally requires gst-plugins-good: media decoding
:: webkitgtk-6.0 optionally requires gst-plugins-good: media decoding

Package (124)                            Old Version    Net Change 

glusterfs                                1:11.1-5        -17,37 MiB
gst-plugins-good                         1.26.2-2         -7,19 MiB
imlib2                                   1.12.5-1         -1,47 MiB
iniparser                                4.2.6-1          -0,06 MiB
libcaca                                  0.99.beta20-5    -2,68 MiB
libshout                                 1:2.4.6-5        -0,20 MiB
libtraceevent                            1:1.8.4-1        -0,39 MiB
libtracefs                               1.8.2-1          -0,38 MiB
multipath-tools                          0.11.0-1         -1,20 MiB
ndctl                                    79-1             -0,94 MiB
taglib                                   2.1-1            -1,97 MiB
brltty                                   6.7-5            -9,54 MiB
capstone                                 5.0.6-1         -14,33 MiB
dtc                                      1.7.2-4          -0,56 MiB
edk2-aarch64                             202411-1       -130,00 MiB
edk2-arm                                 202411-1       -130,00 MiB
edk2-ovmf                                202411-1        -27,05 MiB
gfxstream                                0.1.2-2          -5,47 MiB
glm                                      1.0.1-1         -20,34 MiB
jq                                       1.8.0-1          -0,44 MiB
libaemu                                  0.1.2-5          -1,31 MiB
libcacard                                2.8.1-1          -0,11 MiB
libiscsi                                 1.20.0-2         -0,41 MiB
liblouis                                 3.34.0-1        -12,88 MiB
libslirp                                 4.9.1-1          -0,16 MiB
libtpms                                  0.10.1-1         -1,06 MiB
libxdp                                   1.5.5-1          -0,18 MiB
ninja                                    1.12.1-2         -0,38 MiB
oniguruma                                6.9.10-1         -0,88 MiB
phodav                                   3.0-4            -0,22 MiB
qemu-audio-alsa                          10.0.0-7         -0,07 MiB
qemu-audio-dbus                          10.0.0-7         -0,30 MiB
qemu-audio-jack                          10.0.0-7         -0,07 MiB
qemu-audio-oss                           10.0.0-7         -0,07 MiB
qemu-audio-pa                            10.0.0-7         -0,07 MiB
qemu-audio-pipewire                      10.0.0-7         -0,09 MiB
qemu-audio-sdl                           10.0.0-7         -0,06 MiB
qemu-audio-spice                         10.0.0-7         -0,06 MiB
qemu-base                                10.0.0-7         -0,05 MiB
qemu-block-curl                          10.0.0-7         -0,08 MiB
qemu-block-dmg                           10.0.0-7         -0,06 MiB
qemu-block-gluster                       10.0.0-7         -0,08 MiB
qemu-block-iscsi                         10.0.0-7         -0,09 MiB
qemu-block-nfs                           10.0.0-7         -0,07 MiB
qemu-block-ssh                           10.0.0-7         -0,09 MiB
qemu-chardev-baum                        10.0.0-7         -0,07 MiB
qemu-chardev-spice                       10.0.0-7         -0,07 MiB
qemu-common                              10.0.0-7         -4,44 MiB
qemu-desktop                             10.0.0-7         -0,05 MiB
qemu-docs                                10.0.0-7        -18,47 MiB
qemu-emulators-full                      10.0.0-7         -0,05 MiB
qemu-full                                10.0.0-7         -0,05 MiB
qemu-hw-display-qxl                      10.0.0-7         -0,14 MiB
qemu-hw-display-virtio-gpu               10.0.0-7         -0,12 MiB
qemu-hw-display-virtio-gpu-gl            10.0.0-7         -0,09 MiB
qemu-hw-display-virtio-gpu-pci           10.0.0-7         -0,06 MiB
qemu-hw-display-virtio-gpu-pci-gl        10.0.0-7         -0,06 MiB
qemu-hw-display-virtio-gpu-pci-rutabaga  10.0.0-7         -0,06 MiB
qemu-hw-display-virtio-gpu-rutabaga      10.0.0-7         -0,09 MiB
qemu-hw-display-virtio-vga               10.0.0-7         -0,06 MiB
qemu-hw-display-virtio-vga-gl            10.0.0-7         -0,06 MiB
qemu-hw-display-virtio-vga-rutabaga      10.0.0-7         -0,06 MiB
qemu-hw-s390x-virtio-gpu-ccw             10.0.0-7         -0,06 MiB
qemu-hw-uefi-vars                        10.0.0-7         -0,11 MiB
qemu-hw-usb-host                         10.0.0-7         -0,10 MiB
qemu-hw-usb-redirect                     10.0.0-7         -0,11 MiB
qemu-hw-usb-smartcard                    10.0.0-7         -0,08 MiB
qemu-img                                 10.0.0-7        -10,56 MiB
qemu-pr-helper                           10.0.0-7         -1,05 MiB
qemu-system-aarch64                      10.0.0-7        -29,82 MiB
qemu-system-alpha                        10.0.0-7        -11,42 MiB
qemu-system-alpha-firmware               10.0.0-7         -0,20 MiB
qemu-system-arm                          10.0.0-7        -27,22 MiB
qemu-system-arm-firmware                 10.0.0-7         -0,05 MiB
qemu-system-avr                          10.0.0-7         -7,48 MiB
qemu-system-hppa                         10.0.0-7        -11,51 MiB
qemu-system-hppa-firmware                10.0.0-7         -0,40 MiB
qemu-system-loongarch64                  10.0.0-7        -13,49 MiB
qemu-system-m68k                         10.0.0-7         -9,02 MiB
qemu-system-microblaze                   10.0.0-7        -15,54 MiB
qemu-system-microblaze-firmware          10.0.0-7         -0,07 MiB
qemu-system-mips                         10.0.0-7        -52,79 MiB
qemu-system-or1k                         10.0.0-7        -11,23 MiB
qemu-system-ppc                          10.0.0-7        -30,26 MiB
qemu-system-ppc-firmware                 10.0.0-7         -5,18 MiB
qemu-system-riscv                        10.0.0-7        -29,14 MiB
qemu-system-riscv-firmware               10.0.0-7         -0,56 MiB
qemu-system-rx                           10.0.0-7         -7,52 MiB
qemu-system-s390x                        10.0.0-7        -11,40 MiB
qemu-system-s390x-firmware               10.0.0-7         -0,14 MiB
qemu-system-sh4                          10.0.0-7        -22,82 MiB
qemu-system-sparc                        10.0.0-7        -19,80 MiB
qemu-system-sparc-firmware               10.0.0-7         -1,93 MiB
qemu-system-tricore                      10.0.0-7         -7,72 MiB
qemu-system-x86                          10.0.0-7        -50,20 MiB
qemu-system-x86-firmware                 10.0.0-7         -0,12 MiB
qemu-system-xtensa                       10.0.0-7        -28,67 MiB
qemu-tests                               10.0.0-7         -0,44 MiB
qemu-tools                               10.0.0-7         -2,27 MiB
qemu-ui-curses                           10.0.0-7         -0,09 MiB
qemu-ui-dbus                             10.0.0-7         -0,34 MiB
qemu-ui-egl-headless                     10.0.0-7         -0,06 MiB
qemu-ui-gtk                              10.0.0-7         -0,12 MiB
qemu-ui-opengl                           10.0.0-7         -0,08 MiB
qemu-ui-sdl                              10.0.0-7         -0,09 MiB
qemu-ui-spice-app                        10.0.0-7         -0,06 MiB
qemu-ui-spice-core                       10.0.0-7         -0,11 MiB
qemu-user                                10.0.0-7       -104,09 MiB
qemu-vhost-user-gpu                      10.0.0-7         -0,80 MiB
qemu-vmsr-helper                         10.0.0-7         -1,03 MiB
rutabaga-ffi                             0.1.6-2          -2,36 MiB
sdl2_image                               2.8.8-1          -0,20 MiB
seabios                                  1.16.3-1         -1,04 MiB
socat                                    1.8.0.3-1        -0,52 MiB
spice                                    0.16.0-1         -1,12 MiB
spice-gtk                                0.42-4           -3,02 MiB
spice-protocol                           0.14.5-1         -0,09 MiB
swtpm                                    0.10.1-1         -1,24 MiB
usbredir                                 0.15.0-1         -0,14 MiB
vde2                                     2.3.3-6          -0,69 MiB
virglrenderer                            1.1.1-1          -1,25 MiB
virtiofsd                                1.13.1-1         -2,53 MiB
wolfssl                                  5.8.0-1          -4,00 MiB
zsync                                    0.6.2-5          -0,20 MiB

Total Removed Size:  960,24 MiB

:: Do you want to remove these packages? [Y/n] 

Pacman shows less (I guess due to not handling AUR):

$ pacman -Qtdq
jq
ninja
socat
spice-gtk
swtpm
zsync

I mean I could mark the “to keep” as explicit, but do I want that? (pacman -D --asexplicit package)

Does paru -c also do that?

Probably not.

I don’t have paru. Tried to not install yet another… :wink:

I just tested, paru does not do that. It keeps the optional depends.

I guess yay changed at some point? I stopped using it a while back.

Good to know, but hmm… :thinking: Don’t really want to install and learn yet another tool just to git rid of some clutter. Plus, I quite like(d?) yay because it uses the same option syntax as Pacman.

I wonder what the best strategy is now.

So does paru, I believe?

paru is very similar to yay

For now, I went the way of least resistance: Marked jq, gst-plugins-good, ndctl and multipath-tools as explicit, checked yay -Yc again and removed the crud.

Thanks for your explanations and help!

I’ll mark How to exclude optional deps on a `pacman -Rns`? - #4 by dalto as solution, since that was most goal-oriented. :slight_smile:

My yay -Ps now shows

$ LANG=C yay -Ps
==> Yay version v12.5.0
===========================================
==> Total installed packages: 1470
==> Foreign installed packages: 33
==> Explicitly installed packages: 283
==> Total Size occupied by packages: 13.2 GiB
==> Size of pacman cache /var/cache/pacman/pkg/: 5.5 GiB
==> Size of yay cache /home/matthias/.cache/yay: 2.1 MiB
===========================================
==> Ten biggest packages:
piper-voices-en-us: 1.8 GiB
piper-voices-en-gb: 750.8 MiB
pulsar-bin: 641.1 MiB
piper-voices-de-de: 636.1 MiB
libreoffice-still: 409.5 MiB
chromium: 340.8 MiB
thorium-reader-bin: 332.0 MiB
noto-fonts-extra: 327.4 MiB
noto-fonts-cjk: 298.8 MiB
linux-firmware: 280.9 MiB
===========================================

Wonder if I should clear the Pacman cache, too.
EDIT: YES. :rofl:

EDIT2: Braveheart. Also removed ~60 GB of old Timeshift and Back in Time snapshots. Yay!

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