Skip to content
Latchkey

add-apt-repository: Add a PPA or APT Source

add-apt-repository registers a PPA or APT source so its packages become installable after the next apt-get update.

PPAs and vendor repos extend what apt can install. In CI you want -y so it never prompts, and you must remember to update afterward.

What it does

add-apt-repository writes a source entry into /etc/apt/sources.list.d/ (and, for PPAs, imports the signing key). It does not install packages; after adding a repo you run apt-get update so the new index is fetched.

Common usage

Terminal
# the command lives in software-properties-common
apt-get update
apt-get install -y --no-install-recommends software-properties-common
add-apt-repository -y ppa:deadsnakes/ppa
apt-get update
apt-get install -y --no-install-recommends python3.12

Options

FlagWhat it does
-y / --yesAssume yes; do not prompt for confirmation
--no-updateDo not run apt-get update after adding the repo
-r / --removeRemove a previously added repository
ppa:<owner>/<name>Add a Launchpad PPA
'deb <url> <suite> <components>'Add a raw APT source line

In CI

add-apt-repository is provided by software-properties-common, which minimal images do not include; install it first. Pass -y to avoid the "Press Enter to continue" prompt, and run apt-get update before installing from the new repo.

Common errors in CI

"add-apt-repository: command not found" means software-properties-common is not installed. "E: Unable to locate package <X>" right after adding a PPA means you skipped apt-get update. A PPA that fails with NO_PUBKEY means the key import step did not run; import the key manually into /etc/apt/keyrings.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →