45

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

1
  • It might help give more hints if you mention the package name. Feb 5, 2020 at 18:28

6 Answers 6

37

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

3
  • 1
    I'm a bit confused by the ArchWiki regarding querying local packages: The -Qi flag will also list any packages on your system dependent on the package. E.g. pacman -Qi <package name> | grep 'Required By' returns a list of packages dependent on the queried package. In this case, adding the second i seemingly does not produce any relevant difference. Sep 25, 2023 at 10:54
  • 1
    Also, from what I can tell: pacman -Sii <package> | 'Required By' will list any packages in the official repo dependent on the package, but seemingly not other packages, such as packages in AUR. If you want to see what packages installed on your system that depends the package, especially if you have packages from utside the official repo, pacman -Qi ... is probably the better option. Sep 25, 2023 at 11:10
  • @PålBjartan The second -i doesn't seem to produce any relevant difference. See the description and also try this diff -u <(pacman -Qi openssl) <(pacman -Qii openssl).
    – x-yuri
    Feb 14 at 13:08
18

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

4
  • 1
    Simple list of packages used: pactree <pkg-name> -lu, useful for reinstaling: pacman -S $(pactree <pkg-name> -lu) Jul 18, 2020 at 20:26
  • 1
    @bodolsog: then you can just use -u because it already implies -l Jul 20, 2020 at 18:41
  • 4
    That's not what the OP asked. He asked list the packages that depend ON a particular package. Not to list all the packages that that particular package depends on.
    – Carlo Wood
    Jun 28, 2022 at 21:38
  • It's actually only the last sentence of the answer that answers OP's question. I suggest you put this at the top of your comment. Sep 25, 2023 at 11:30
5

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

4

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.

2

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}'
1

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:

  1. 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
  2. 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).

3
  • There seems to be no point in second -i with -Q. Try e.g. diff -u <(pacman -Qi openssl) <(pacman -Qii openssl).
    – x-yuri
    Feb 14 at 13:04
  • @x-yuri Thanks for bringing this up and also providing a working example. You are right, there is not difference in the manual, but in action I can see a difference. the single -i does now show Backup Files where as the -ii does. But this is besides the point as we are interested in Required By field. I will update the post to reflect this. Feb 15 at 12:43
  • Actually there is a difference in the man page: "Passing two --info or -i flags will also display the list of backup files and their modification states." But yeah, that's of no concern here. UPD. But if you meant the Arch wiki page, then -Qii can be replaced with -Qi there I believe.
    – x-yuri
    Feb 15 at 13:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .