Skip to content
Latchkey

add-apt-repository: Usage, Options & Common CI Errors

add-apt-repository adds a PPA or third-party APT source and its signing key.

add-apt-repository is how you enable extra package sources (PPAs, the universe component, vendor repos) on Ubuntu. In minimal CI images it is missing until you install software-properties-common.

What it does

add-apt-repository writes a new entry under /etc/apt/sources.list.d/ and, for PPAs, fetches the signing key. After adding a source you must run apt-get update so the new packages appear in the index. It ships in the software-properties-common package, which slim images omit.

Common usage

Terminal
apt-get update && apt-get install -y software-properties-common
add-apt-repository -y ppa:deadsnakes/ppa
add-apt-repository -y universe
apt-get update && apt-get install -y python3.12

Common errors in CI

"add-apt-repository: command not found" - install software-properties-common first. After adding a repo, "Unable to locate package" persists until you run apt-get update again. PPAs without a matching release for your Ubuntu codename fail with "the repository does not have a Release file"; pick a PPA that supports your base image's codename. In headless CI always pass -y so the "Press [ENTER] to continue" prompt does not hang the job.

Options

FlagWhat it does
-y / --yesAssume yes (no interactive prompt)
ppa:user/nameAdd a Launchpad PPA
-r / --removeRemove a previously added repository
-u / --updateRun apt-get update after adding

Related guides

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