I got this weird thing going on where,

pacman -S -w awesome xorg-xinit xorg-server xorg-server-utils

pacman doesn't download all the required dependencies.

The reason for downloading the packages is because I'm creating a local repo with only the specific packages to my neededs. (instead of downloading the whole repo since the Arch community doesn't want you to do this because of bandwidth limitations, which is respect)

Now, the packages defined above downloads nicely, it does download xorg-server and so on, and -w ensures they don't get installed. But -S should also download all the dependencies which it doesn't for whatever reason.

The output when trying to install the above packages using the local repo later on results in:

warning: cannot resolve "xorg-xset", a dependency of "xorg-server-utils"
warning: cannot resolve "xorg-xauth", a dependency of "xorg-xinit"

and the list goes on... inspecting the repo surely the packages are missing and has never been downloaded anywhere.

Any ideas to why this is? Have I missed something? Logically or parameter wise?

1 Answer 1


As pointed out by Earnestly and demonicmaniac3 over at #archlinux irc channel, this is because pacman won't re-download anything if it's already locally installed. But it will download whatever it is you're specifically instructing it to, which make a whole lot of sense come to think of it.

This means if you're trying to download packages intended for a custom/local repo, you need to either make sure the packages you're about to download is not installed locally or do one of these options:

Use a empty package database temporarly/locally

pacman -y --dbpath /tmp ...

This will create the illusion that nothing is installed locally and every single package needed is downloaded. This also requires you to do -y since there's no master package-list in your made up database.

Perform a system upgrade

pacman -Syuw ...

This should re-install/upgrade any package may it be installed or not already.
Note: Not verified (I know too little about pacman's logic and am in a time pickle to test it)

Isolating downloaded files

As pointed out in the comments, you most likely want to place the downloaded files in a separate directory so you can use them, this is done with --cachedir:

pacman --cachedir /tmp/somewhere ...

Final example

sudo pacman -Syw --cachedir /tmp/somewhere --dbpath /tmp/pacmandb base base-devel linux linux-firmware

And then you most likely want to add it to a mirror using repo-add by issuing something like:

repo-add /tmp/somewhere/my_mirror.db.tar.gz /tmp/somewhere/{*.pkg.tar.xz,*.pkg.tar.zst}

Generate a dependency-list using expac

expac -S '%E' -l '\n' base base-devel linux linux-firmware | tr '\n' ' '

Calling expac on the <package string> (all the packages you are about to download) would give you a list of packages needed to run whatever it is you're downloading. You could use this list to fetch/add to your already existing string of packages scheduled for installation.

expac separates each individual dependency in a one-liner by default but splits them up between packages, so we convert each one-liner string into multiple new lines, and then use tr to convert newlines to spaces.

I prefer the expac version since it holds up programmatically and would be useable in many scripts, but the quick and "dirty" version is to simply redirect the database which pacman checks.

  • 1
    You may want to look into specifying --cachedir if you are going to use the local repository for multiple machines with different packages. It also takes care of have to deal with multiple versions of the same package in the repository.
    – StrongBad
    Dec 11, 2017 at 15:50
  • I get the error failed to initialize alpm library (could not find or read directory: /tmp/pacmandb). How do I create an empty package database to use with the --dbpath option? Sep 14, 2020 at 4:47
  • 1
    @BrandonMiller mkdir -p /tmp/pacmandb should do the trick.
    – Torxed
    Sep 14, 2020 at 6:16
  • @Torxed Oh, that's embarrassing, I was thinking it was expecting some sort of database file for some reason. Wasn't until I just now looked at the pacman manual that it dawned on me that, as suggested by the name --dbpath, it's expecting a directory. Sep 14, 2020 at 7:30
  • As a side note, when trying the trick using expac, I seemed that either it doesn't include dependencies of dependencies, or I did something wrong. Sep 14, 2020 at 7:31

You must log in to answer this question.

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