You may see the error `Could not get lock /var/lib/apt/lists/lock` on the machine executor when attempting to run `apt- ` if there is currently a networking issue that is causing the spinup step to keep the update process alive.
Using the Docker executor if updating this type of networking issue should display within your step output the download speed of each mirror, showing which is potentially causing the issue.
With Docker, you may not need to run apt-get update if you rebuild your Docker image on a regular basis. Active convenience images maintained by CircleCi are rebuilt on a weekly basis.
Here are some options for working around slow or broken mirrors.
Wait for network
This command will kill any `apt-get` process that might be running in the background already, and then allow up to an hour to download the package(s) if need be. This may not be ideal if you are on a Usage-based plan as this may significantly increase container time in the event of a networking issue. However, this may be desired for critical applications where waiting on the network is preferred.
- run: no_output_timeout: 1h command: | set -e killall apt-get apt-get -q -y update apt-get -q -y install any packages here
Sometimes official mirrors go down or are slow, or move to new URLS. If you have a known list of good mirrors, you can manually set them.
You can modify this example by replacing the sources with known good mirrors for your base distro.
- run: |
sudo rm /etc/apt/sources.list
echo "deb http://archive.debian.org/debian/ jessie-backports main" | sudo tee -a /etc/apt/sources.list
echo "deb-src http://archive.debian.org/debian/ jessie-backports main" | sudo tee -a /etc/apt/sources.list
echo "Acquire::Check-Valid-Until false;" | sudo tee -a /etc/apt/apt.conf.d/10-nocheckvalid
echo 'Package: *\nPin: origin "archive.debian.org"\nPin-Priority: 500' | sudo tee -a /etc/apt/preferences.d/10-archive-pin
sudo apt-get update