Skip to content
Latchkey

apt-get install: Usage, Options & Common CI Errors

apt-get install adds packages and their dependencies on Debian and Ubuntu.

apt-get install is the workhorse of Debian-based CI images. The two things that break it in pipelines are a stale index (run apt-get update first) and interactive prompts that hang a non-TTY job.

What it does

apt-get install downloads and installs the named packages plus their dependencies from the configured repositories. In CI you pass -y to skip the confirmation prompt and set DEBIAN_FRONTEND=noninteractive to suppress configuration dialogs (e.g. tzdata).

Common usage

Terminal
apt-get update && apt-get install -y curl git ca-certificates
DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata
apt-get install -y --no-install-recommends build-essential
apt-get install -y nginx=1.24.0-1                 # pin a version
rm -rf /var/lib/apt/lists/*                        # shrink the layer

Common errors in CI

"E: Unable to locate package X" almost always means apt-get update was not run (empty index) or the package lives in a repo you have not added (universe, a PPA, NodeSource). "E: Package X has no installation candidate" means the name exists but no version matches your release. A job that hangs forever is usually a config prompt - set DEBIAN_FRONTEND=noninteractive and -y. "dpkg was interrupted" requires dpkg --configure -a to recover.

Options

FlagWhat it does
-y / --yesAssume yes to prompts (required in CI)
--no-install-recommendsSkip recommended (non-essential) packages
--reinstallReinstall an already-installed package
--allow-downgradesPermit installing an older version
-t <suite>Pull from a specific release/suite

Related guides

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