Created
October 31, 2017 22:40
-
-
Save askb/8ebc682d0def8ff73649ce48c186aa94 to your computer and use it in GitHub Desktop.
Workaroud for apt "Could not get lock /var/lib/dpkg/lock"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) | |
# E: Unable to lock the administration directory (/var/lib/dpkg), is another process using | |
# Wait for any background apt processes to finish | |
# There seems to be a backgroud apt process that locks /var/lib/dpkg/lock | |
# and causes our apt commands to fail. | |
while pgrep apt > /dev/null; do sleep 1; done |
$ apt install expect
[sudo] password for askb:
/var/lib/dpkg/lock:
Waiting on apt lock...
/var/lib/dpkg/lock:
Waiting on apt lock...
/var/lib/dpkg/lock:
Waiting on apt lock...
/var/lib/dpkg/lock:
Waiting on apt lock...
/var/lib/dpkg/lock:
Waiting on apt lock...
/var/lib/dpkg/lock:
Waiting on apt lock...
/var/lib/dpkg/lock:
Waiting on apt lock...
/var/lib/dpkg/lock:
Waiting on apt lock...
/var/lib/dpkg/lock:
Waiting on apt lock...
/var/lib/dpkg/lock:
Waiting on apt lock...
/var/lib/dpkg/lock:
Waiting on apt lock...
/var/lib/dpkg/lock:
Waiting on apt lock...
/var/lib/dpkg/lock:
Waiting on apt lock...
/var/lib/dpkg/lock:
Waiting on apt lock...
/var/lib/dpkg/lock:
Waiting on apt lock...
/var/lib/dpkg/lock:
Waiting on apt lock...
/var/lib/dpkg/lock:
Waiting on apt lock...
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-headers-4.4.0-124 linux-headers-4.4.0-124-generic linux-image-4.4.0-124-generic linux-image-extra-4.4.0-124-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
tcl-expect
The following NEW packages will be installed:
expect tcl-expect
0 upgraded, 2 newly installed, 0 to remove and 20 not upgraded.
Need to get 241 kB of archives.
After this operation, 538 kB of additional disk space will be used.
Do you want to continue? [Y/n] n
Abort.
Hi man, thank you for this timesaver )
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another alternative is to use an bash alias:
echo "alias apt='while [ \$(fuser \"/var/lib/dpkg/lock\") ]; do echo \"Waiting on apt lock...\"; sleep 1; done; sudo apt \"\$@\"'" > ~/.bashrc