Vagrant and Xenial Lock File Issue Finally Solved

After weeks of getting the error message Unable to lock the administration directory (/var/lib/dpkg/), is another process using it? and Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable), I have a solution that actually works.

systemctl stop apt-daily.service
systemctl kill --kill-who=all apt-daily.service

# wait until `apt-get updated` has been killed
while ! (systemctl list-units --all apt-daily.service | fgrep -q dead)
  sleep 1;

I added this script to run early in the Vagrantfile and it finally allowed the process to get killed before moving on through the rest of the script. I’m surprised at how long it actually takes to actually die and now I understand why I ran into this error often.

[1] Source

[2] A different solution that did not work for me but gives more info on the problem

Rubén Bagüés

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s