What do you think? Discuss, post comments, or ask questions at the end of this article [More about me]

Skip to end of metadata
Go to start of metadata

You might need/want to install a package on your Arch based distro (e.g. Arch, Manjaro, ArcoLinux, etc..) with all its optional dependencies.  You could do this from your distro's (generally GUI based) package helper (like Manjaro's pamac-manager) but we're going to cover doing this from the command line using standard pacman (which your Arch based distro will have).


The approach we're using here uses two steps:

  1. install main package
  2. install optional dependencies as dependencies (--asdeps)

Install main package first

As mentioned, we need to install the main package first.  Let's use wine as an example (chose wine since it has quite a few optional dependencies).

Install the main wine package as per usual:

sudo pacman -S wine

Once you've installed this, let's move onto installing all optional dependencies.

Install all optional dependencies (as dependencies)

Now, let's install all optional dependencies.  We're going to use the pacman -Si command which will list information about the package (including optional dependencies).  The rest of the following command is simply processing the output to only show the optional dependency packages:

sudo pacman -S --asdeps --needed $(pacman -Si wine | sed -n '/^Opt/,/^Conf/p' | sed '$d' | sed 's/^Opt.*://g' | sed 's/^\s*//g' | tr '\n' ' ')

Replace pacman -Si wine with pacman -Si <package> where <package> is the package you want to install all the optional dependencies for.

The --needed option will stop pacman from reinstalling a package if it is already installed.  In other words, we probably don't want to reinstall a package and mark it as a dependency if it is already on our system (either installed via another package or installed explicitly).

It's important to note that we should use the --asdeps argument here to mark these packages's install reason as a "dependency" (otherwise, these packages will be marked as "explicitly" installed).  This means that if you uninstall the main package, these optional dependencies will be orphaned - which you can then safely uninstall with a single command (which you can run often to clean up any orphans):

sudo pacman -Rns $(pacman -Qtdq)


  1. https://wiki.archlinux.org/index.php/pacman
  2. https://wiki.archlinux.org/index.php/Pacman#Pactree
  3. https://wiki.archlinux.org/index.php/Pacman/Tips_and_tricks#Removing_unused_packages_.28orphans.29