If a Linux job hangs during apt, apt-get, or apt install and eventually fails with Too long with no output (exceeded 10m0s), the package manager may be waiting for interactive input. CircleCI jobs run without a terminal, so prompts that ask you to confirm service restarts or configuration choices will block until the no-output timeout.
This is common on machine executors (Ubuntu VM images) and can also occur in Docker jobs that run apt on Debian- or Ubuntu-based images.
Symptoms
- A step runs
sudo apt update,sudo apt install, orsudo apt-get install. - Output stops at a prompt about restarting services, configuring packages, or similar.
- The step ends with
Too long with no output (exceeded 10m0s)orcontext deadline exceeded. - Using
-yalone may not resolve the hang if the prompt comes from a post-install configuration step rather than a yes/no package prompt.
Cause
On recent Ubuntu images, apt may interactively ask whether to restart services when libraries they depend on are upgraded. In CI there is no one to answer those prompts.
Unlike some other CI platforms, CircleCI machine and Docker executors do not set DEBIAN_FRONTEND=noninteractive globally for your job steps. You need to set it in your config, project environment variables, or a context.
If the hang is on brew install or the Homebrew install script instead of apt, the fix is different. See Homebrew brew install hangs on macOS and Linux executors.
Resolution
Option 1: Set DEBIAN_FRONTEND=noninteractive on the job (recommended)
jobs:
build:
machine:
image: ubuntu-2204:current
environment:
DEBIAN_FRONTEND: noninteractive
steps:
- checkout
- run:
name: Install dependencies
command: |
sudo apt-get update
sudo apt-get install -y <package>You can also add DEBIAN_FRONTEND=noninteractive to a context shared across projects.
Option 2: Export in the step
- run:
name: Install dependencies
command: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
sudo apt-get install -y <package>Option 3: Prefix individual commands
- run:
name: Install dependencies
command: |
sudo DEBIAN_FRONTEND=noninteractive apt-get -yq update
sudo DEBIAN_FRONTEND=noninteractive apt-get -yq install <package>Always combine non-interactive mode with -y (or --yes) on install commands.
If prompts persist: needrestart
Some Ubuntu images use needrestart, which can still prompt about restarting services. If you still see interactive output after setting DEBIAN_FRONTEND, add this before your apt commands:
- run:
name: Configure apt for non-interactive use
command: |
sudo sed -i "s/#\$nrconf{restart} = 'i';/\$nrconf{restart} = 'a';/g" /etc/needrestart/needrestart.confThis tells needrestart to restart services automatically instead of prompting.
Verification
Re-run the pipeline. The apt step should complete without stopping at a prompt, and packages should install successfully.
Comments
Article is closed for comments.