List all packages that depend on a certain package with pacman
I have two packages which are in conflict after installing a new one with pacman on arch.
How can I list all installed packages that are depending on the ones in conflict?
Or more general:
How can I list all installed packages that are depending on a certain other package
To list the dependencies use pacman -Si
(i.e., pacman --sync --info
)
or pacman -Qi
(i.e., pacman --query --info
).
To list the reverse dependencies: pacman -Sii
(i.e., pacman --sync --info --info
; yes two infos).
Arch Linux: Querying package dependencies
How can I list all installed packages that are depending on a certain other package
For one level dependency use pacman -Qi package_name | grep 'Depends On'
e.g:
$ pacman -Qi jack | grep 'Depends On'
Depends On : alsa-lib db glibc gcc-libs libsamplerate libzita-alsa-pcmi.so=0-64 libzita-resampler.so=1-64
To view the dependency tree of a package use pactree
which is owned by pacman-contrib
e.g:
$ pactree jack
jack
├─alsa-lib
│ ├─glibc
│ │ ├─linux-api-headers provides linux-api-headers>=4.10
│ │ ├─tzdata
│ │ └─filesystem
│ │ └─iana-etc
│ ├─alsa-topology-conf
│ └─alsa-ucm-conf
├─db
│ ├─gcc-libs
│ │ └─glibc provides glibc>=2.27
│ └─bash provides sh
│ ├─readline provides readline>=7.0
│ │ ├─glibc
│ │ ├─ncurses
│ │ │ ├─glibc
│ │ │ └─gcc-libs
│ │ └─ncurses provides libncursesw.so=6-64
│ ├─glibc
│ └─ncurses
├─glibc
├─gcc-libs
├─libsamplerate
│ └─glibc
├─zita-alsa-pcmi provides libzita-alsa-pcmi.so=0-64
│ ├─alsa-lib
│ ├─gcc-libs
│ └─glibc
└─zita-resampler provides libzita-resampler.so=1-64
├─gcc-libs
└─glibc
To view the dependent tree of a package, pass the reverse flag -r
to pactree
Another way to do it is just e.g. sudo pacman --remove python2
then you will see:
$ sudo pacman --remove python2
[sudo] password for elijah:
checking dependencies...
error: failed to prepare transaction (could not satisfy dependencies)
:: removing python2 breaks dependency 'python2' required by cython2
:: removing python2 breaks dependency 'python2' required by python2-appdirs
:: removing python2 breaks dependency 'python2' required by python2-cairo
:: removing python2 breaks dependency 'python2' required by python2-click
:: removing python2 breaks dependency 'python2' required by python2-colorama
:: removing python2 breaks dependency 'python2' required by python2-fasteners
:: removing python2 breaks dependency 'python2' required by python2-funcsigs
:: removing python2 breaks dependency 'python2' required by python2-giturlparse
:: removing python2 breaks dependency 'python2' required by python2-gobject
:: removing python2 breaks dependency 'python2' required by python2-gobject2
:: removing python2 breaks dependency 'python2' required by python2-linecache2
:: removing python2 breaks dependency 'python2' required by python2-mock
:: removing python2 breaks dependency 'python2' required by python2-monotonic
:: removing python2 breaks dependency 'python2' required by python2-numpy
:: removing python2 breaks dependency 'python2' required by python2-ordered-set
:: removing python2 breaks dependency 'python2' required by python2-pyparsing
:: removing python2 breaks dependency 'python2' required by python2-pypdf2
:: removing python2 breaks dependency 'python2' required by python2-pyxdg
:: removing python2 breaks dependency 'python2' required by python2-setuptools
:: removing python2 breaks dependency 'python2' required by python2-sh
:: removing python2 breaks dependency 'python2' required by python2-yaml
-> exit status 1
I noticed that with pacman --sync --info --info
it was showing me every package that depended on it, not necessarily the ones on my system, I think.
The previous answers are incorrect. If you want to know which packages depend on package X, use the following command:
pacman -Qi | grep -E 'Depends On|Name' | grep -B 1 -E 'Depends On.*PACKAGE_X.*' | grep Name | awk -F ':' '{print $2}'
For multiple level dependencies use pactree
a command that comes with pacman
package.
With the option -r
you can find the top application/packages that depend on a given package.
Here an example:
pactree -r gst-plugins-bad-libs
gst-plugins-bad-libs
├─gst-plugins-bad
│ ├─cheese
│ └─gnome-video-effects
│ └─cheese
├─gtk4
│ ├─gnome-desktop-4
│ │ └─xdg-desktop-portal-gnome
│ │ └─xdg-desktop-portal
│ │ └─flatpak
│ └─libadwaita
│ └─xdg-desktop-portal-gnome
└─libcheese
└─cheese
In this case the top applications are flatpak
and cheese
Some existing answers are wrong as they are not searching reverse dependency, some others are missing some details that may cause confusion, and some are not using pacman
which is what the OP asked for, although I personally like the answer as it gives the right answer. After some minutes of reading and searching, this is what I could gather:
Assume we have a package named "X" and we want to see which packages depend on X. Now we have two conditions:
- If you do not have the package X installed and just want to get the info from the repos, you can use
pacman -Sii X
- If you have it installed (which this is what answers the OP’s question), you should use
pacman -Qi X
In both of the commands above, you should look the Required By:
and Optional For:
fields. The following is example of highway-git
which is required by libjxl
:
❯ pacman -Qi highway-git
Name : highway-git
Version : 1.0.4.r256.g89c0310-1
Description : A C++ library for SIMD (Single Instruction, Multiple Data) (git version)
Architecture : x86_64
URL : https://github.com/google/highway/
Licenses : Apache
Groups : None
Provides : highway
Depends On : gcc-libs
Optional Deps : None
Required By : libjxl
Optional For : None
Conflicts With : highway
Replaces : None
Installed Size : 5.45 MiB
Packager : Unknown Packager
Build Date : Wed 31 May 2023 11:33:59 AM EEST
Install Date : Wed 31 May 2023 11:36:16 AM EEST
Install Reason : Installed as a dependency for another package
Install Script : No
Validated By : None
It worth mentioning that the pacman -Sii X
does not work if the X is an AUR package, but pacman -Qi X
does work on AUR because it is already installed and the info exists on your computer.
For further reading you can go to Arch wiki for Pacman. The info above is very briefly mentioned in the first row of the table (at least at the time of writing this answer).
pactree
is a good tool to print reverse dependencies. If you want to reduce the output you can set the -d
flag to set the depth,e.g.:
pactree -r -d 1 jack