41

I often encounter the "Another app is currently holding the yum lock; waiting for it to exit..." message when trying to install an app and I have to kill yum manually. How can I avoid that? Is there any simple method to unlock yum?

It seems that only one instance of yum can be running. Is it the same with other package mangers (apt-get, pacman)?

1
  • In my case, I was connected to a server via VPN. Once I ran sudo yum -y update, all packages were getting updated, along with open-VPN. Once open-VPN package got updated, I was disconnected from the VPN. I log back in, try the yum update again and it says the same thing.
    – arun
    Sep 16, 2017 at 13:56

6 Answers 6

33

I think it is caused by PackageKit. You have to check for PackageKit and disable it (I assume it is CentOS 7 with systemctl, otherwise you can use service and chkconfig) (as mentioned in comments, the service name is packagekit not packagekitd):

systemctl stop packagekit
systemctl disable packagekit

Another approach (On CentOS/RHEL 6, Fedora 19 or earlier) is to open /etc/yum/pluginconf.d/refresh-packagekit.conf with a text editor, and change enabled=1 to enabled=0.

Or you can completely remove it:

yum remove PackageKit
3
  • 3
    It is called packagekit.service on my Centos 7 May 25, 2017 at 9:21
  • In my case, I simply ran systemctl stop packagekit and then the yum lock was freed.
    – T-Heron
    Oct 29, 2017 at 11:52
  • I moved to docker and cannot verify this fix, for the time being I mark this as an answer. thanks. May 6, 2020 at 21:43
12

do the following to solve the problem:

cd /var/run
rm -f yum.pid

you could also update your yum afterward

yum -y update
2
  • 3
    This is fighting symptoms and not fixing the real cause. Jun 20, 2018 at 9:34
  • Yikes. It's hard to recommend this under any circumstances, because that .pid file is there for a reason. The same "Another app is currently holding the yum lock" message the original poster mentioned will also tell you the PID of the running process holding the lock. At the very least, you'd want to kill or kill -HUP that process to give it a chance to try to finish what it's doing, lest you risk corrupting YUM's internal state. Feb 25, 2022 at 9:28
6

You can unlock yum by following two simple steps,

1) Run ps aux | grep yum to see which process is locking yum. 2) kill <process_id> to kill the process.

Again run ps aux | grep yum to see if the process is killed or not. Yum will be unlocked after killing the process.

3
  • 3
    this "works" but is probably bad practice Oct 26, 2016 at 16:38
  • 1
    This works in select circumstances. I have encountered a situation where systemd restarts the packagekit process before I can start my own yum command. And yes, also it is probably bad practice to kill the PID instead of gracefully telling packagekit to not run.
    – 0xSheepdog
    Aug 8, 2017 at 21:34
  • It can also solve problems like [4]+ Stopped <THE COMMAND> May 16 at 14:09
1

In my case, I was connected to a server via VPN (open VPN). Once I ran sudo yum -y update, all packages were getting updated, along with open-VPN. Once open-VPN package got updated, I was disconnected from the VPN. I logged back in, tried the yum update again and it said another process is holding the yum lock.

I checked with ps ax | grep yum and the old process was still running. I waited for 5 min for it to "finish", but the process just kept running. Then I thought I could "pull the trigger" with kill, so I ran

kill <PID of the yum update process>

That didn't kill the process. Tried that a few more times, and still no success.

Finally I had to really pull the plug on it, by running:

kill -9 <PID of the yum update process>

Tried yum update again, but same issue. I then ran:

rm -f /var/run/yum.pid

and then tried update and got this output:

Loaded plugins: fastestmirror
Setting up Update Process
Loading mirror speeds from cached hostfile
 * base: mirror.sigmanet.com
 * epel: mirror.sjc02.svwh.net
 * extras: mirrors.vpsie.com
 * updates: mirror.pac-12.org
No Packages marked for Update

Believe everything is good, but I didn't like pulling the plug on so many things!

1

systemctl disable packagekit is not enough. packagekit will be running upon reboot. Use the mask command instead of the disable command.

[root@localhost yum.repos.d]# systemctl mask packagekit
Created symlink from /etc/systemd/system/packagekit.service to /dev/null.

Then upon reboot you will see ...

[sri@localhost ~]$ systemctl status packagekit
● packagekit.service
   Loaded: masked (/dev/null; bad)
   Active: inactive (dead)
1
0

uninstalling PackageKit will also remove the software gui. instead do this, this has been effective for me with RHEL >= 7.6.

create /etc/yum/pluginconf.d/refresh-packagekit.conf

[main]
enabled=0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .