Report this

What is the reason for this report?

The lock file /var/lib/dpkg/lock-frontend still exists between apt-update and apt-install

Posted on August 13, 2021

Hi,

I am creating a droplet (nyc1/4vcpu-8gb/ubuntu-20-04-x64) with doctl and, when accessible (ping on ip address followed by nc on ssh port) I send and run the following bash script:

#!/bin/bash

apt-get update
apt-get install -y apt-transport-https \
                   curl                \
                   tmux                \
                   zsh                 \
                   zip                 \
                   inotify-tools

But for some reason there is some kind of race condition between the apt-update and apt-install because the lock file (/var/lib/dpkg/lock-frontend) seems not to be released, like the following snippet:

Get:29 http://archive.ubuntu.com/ubuntu focal-backports/main amd64 Packages [2,568 B]
Get:30 http://archive.ubuntu.com/ubuntu focal-backports/main Translation-en [1,120 B]
Get:31 http://archive.ubuntu.com/ubuntu focal-backports/main amd64 c-n-f Metadata [400 B]
Get:32 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [5,800 B]
Get:33 http://archive.ubuntu.com/ubuntu focal-backports/universe Translation-en [2,068 B]
Get:34 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 c-n-f Metadata [288 B]
Fetched 5,354 kB in 2s (2,995 kB/s)
Reading package lists... Done
E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 2194 (apt-get)
N: Be aware that removing the lock file is not a solution and may break your system.
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?

Am I doing something wrong or maybe is it a bug?

Cheers,

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.