Update single package with pacman on Arch Linux

There are times I need to update a single package with pacman, even though I try to update my Arch Linux regularly, once per week if possible. Typically, this happens with packages that are network connected and a minimum version is required to run. Discord, the chat service, forces this need very regularly.

Risks involved with updating a single package

I’m going to show you how you can update a single package with pacman (or yay, or insert your favorite AUR wrapper), but I have to mention the risks involved with doing a partial update.

Arch Linux is a rolling release linux distro. Thus, rolling release distributions are meant to be updated in their entirety and not in an ad-hoc fashion.

Updating a single package brings the risk of breaking a dependency and could very well leave you with a broken system. Fortunately, at least with the discord package, it’s been a very smooth process that has yet to cause me any grief.

Update the local package database

First, we need to update our local package database. If we skip this step, all we’ll be able to do is re-install the same version of the package that we already have installed. To update your local package database without updating your entire system, run:

% pacman -Sy
Zsh

Update a single package

Next, we’ll update the package to the latest version. This is actually the same command that we’d run to install a package for the first time. Because the local database is synchronized, the newer version is the eligible candidate:

% pacman -S package
Zsh

Conclusion

Fortunately, there’s really not much to it. Simply update the local package database and then run the synchronize command on the package in question.

As mentioned, partial updates like this comes with the risk of breaking your system. Suspect this risk goes up when you’re installing things like libraries, but for stand-alone, non-system packages, things tend to be smooth.

Josh Sherman - The Man, The Myth, The Avatar

About Josh

Husband. Father. Pug dad. Musician. Founder of Holiday API, Head of Engineering and Emoji Specialist at Mailshake, and author of the best damn Lorem Ipsum Library for PHP.


If you found this article helpful, please consider buying me a coffee.