Score:0

"dpkg: error: dpkg front end lock is locked by another process"

in flag
Aki

As part of my workflow I'm using Ubuntu server 20.04.3.

So I prepare the image for the VM and deploy it using Ansible.

Since it is env with no access to the internet all packages I'm installing have been previously downloaded .deb. by execution simple shell command:

dpkg -i deb_1.deb  deb_2.deb deb_3.deb deb_4.deb 
dpkg -i deb_5.deb  deb_6.deb deb_7.deb deb_8.deb 

Sometimes ~5% of cases, I'm receiving this error totally sporadically, can occur on first installation

"stderr_lines": ["dpkg: error: dpkg frontend lock is locked by another process",
"E: Sub-process dpkg --set-selections returned an error code (2)", "E: Executing dpkg failed. Are you root?"]

I have tried to solve this by:

  1. Before each installation step perform manual lock file deletion
  • /var/lib/dpkg/lock
  • /var/lib/dpkg/lock-frontend
  • /var/cache/apt/archives/lock

But even after manual deletion the error continue to appears.

  1. Tried to install packages with Ansible apt module and "deb" arg - but the behavior is the same.

  2. Tried to figure out what process actually owns the lock files with "lsof", but file was not owned by any process.

Is there is some way to fix this strange and buggy behavior?

What process is responsible for creating lock files sometimes on system startup?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.