 In this video, I'm going to show you some ways to solve some of the problems that you may occasionally run into if you run Arch Linux or an Arch Linux based distribution. Specifically, I want to talk about the package manager Pacman, because occasionally you will get errors if you're installing software or moving software, just updating the system. And this happened to me today. I just tried to update my system. I ran a sudo pacman dash capital S lowercase yu, you know, to update all the packages on my system. And there were about 450 packages that needed to be updated because I guess I haven't updated it in about a week or so. And I have a lot of stuff on my system. Now, most of those 400 and some odd packages are various small little Haskell libraries. If I scroll up, you see a lot of Haskell stuff on my system, because of a lot of the stuff I do with X mode ad and all the GTK stuff I've been doing recently with Haskell, but it couldn't run this update. And the reason it couldn't run this update is because it tried to import some PGP keys. And you see, I get this error here, invalid or corrupted package PGP signature. So whatever new key it was trying to pull in, that key is invalid or corrupted according to Pacman. So it just crapped out, right? I couldn't update my system. Now, how do you solve this problem? Having been around for a while, this is not the first time I've had this issue. So I actually do know the error here. So I'm going to clear the screen. I'm going to zoom in. What you need to do anytime you run into this invalid or corrupted PGP signature problem is you need to actually update the Arch Linux key ring before you do your update. So what I need to do is actually do a sudo pacman dash sy for sync. And then we're going to sync the Arch Linux dash key ring. And then, of course, give it your sudo password. And it says proceed with installation. So that's going to install the latest Arch Linux key ring. And now it has those new keys, the keys I guess it couldn't find before. So if I just do an up arrow and go back to sudo pacman dash syu, this should work now. And the update finished just fine. There were no errors or anything. So that's all you need to do is just update the Arch Linux key ring. That's something that you that that problem that error doesn't come up that often. I probably see that particular error, I don't know, two, three times a year. That's very infrequent that you get that particular error. And that'll happen on any Arch Linux based distribution, anything that uses the Arch repositories. I'm on Arco. Another problem you will occasionally run into with the pacman package manager, I run into this problem, probably more than most people because I have my own repository of software. I maintain my own third party Arch packages repository. And because I play around with a lot of different stuff with pacman, you know, occasionally I try to do an update on my system. And it will just fill it will say filled and it says unable to lock database. And it complains about this particular file slash vor slash lib slash pacman slash db dot lock. So it's database lock file. And all you need to do since it gives you the path to that fall, you need to do a sudo RM for remove and then that file just remove that file from your system, then rerun the sudo pacman syu and that should work. And that's perfectly safe to do you that removing that lock file does nothing. It's generated again for you anyway. So it does no harm to your system. So anytime you run into that error, just sudo RM that file. Another issue that I sometimes run into again probably because I maintain my own repository of software and things get out of whack. Sometimes things get out of sync. And sometimes it's a good idea to remove the cache files on the system of the force force that your pacman cache. Now there's a couple of different ways you can do this. Typically I run this command and this command here, according to the arch documentation could be dangerous. They don't really recommend people to use this command, but this is pacman space dash capital S lowercase cc. It removes all of the cache files, all the pacman cache data on the system. And I've never had an issue with this command. I've used it for years. I mean, it's not something I run every day, but I probably have run this command. I don't know half a dozen times probably in the past year when I've run into various pacman errors and this helped sort things out. But these days, arch has a specific tool called pac cache that you're supposed to run. So sudo pac cache all one word space dash R for remove. And if you don't give it any other arguments other than the dash R, it removes everything in the cache folder except the last three, uh, cached versions. So it doesn't remove everything, but it removes everything older than the last three, uh, cached snapshots, if you will. And you can see it removed 1,303 packages and it removed a 2.6 gigabytes of data. So actually I hadn't run a, uh, pac cache remove vinyl wall. It's probably been a few weeks and you can see how much data, how much, uh, just extra space is being wasted by keeping all those cache files located on the system. So not only does removing the cache sometimes clear up errors you might be getting in pacman, but obviously it frees up disk space. Now, because this particular command is so useful because it saves you disk space, right? You probably want to set up some kind of automatic thing to make this run every now and then. Like you could do this with a Cron job or a system D timer, but of course on arch Linux, you have pacman hooks where when the package manager does something, when the package manager install software, remove software, update software, you can tell it whatever trigger, you know, when this happens, I want you to run this command. And what I'm going to do is I'm going to tell pacman, Hey, every time you do anything, I want you to run sudo pac cache dash R. That way we only always have the latest three versions of the cache and it deletes everything older than that. That way I never have this problem where I have all of these gigabytes of just space being taken up for no real reason. So let me switch back to my desktop and I'm in a terminal here. Let's CD into slash etsy slash pacman dot D slash hooks. Now this is the directory where all of your pacman hooks should be. If for some reason you don't have this directory, make this directory here on Arco, the directory already exists. And I've actually got a bunch of hooks already here. Many of these were here by default in Arco Linux. Some of these I added myself the recompile Xmonad hook if I open this. So this particular hook file, what it does the trigger is anytime pacman does an upgrade of any package with the name Haskell at the beginning Haskell asterisk. So we run an upgrade and as part of that upgrade anything that begins with the word Haskell. Then what I want you to do is run the following action. I want you to execute this command. The command is Xmonad dash dash recompile. That's essentially what we're running. So it recompiles Xmonad every time any Haskell library of any kind is upgraded. That is essentially all that hook does. So let me quit out of that. What we need to do, let's create a hook for running the pac-cache-ar command. So we need sudo privileges to make a hook in this directory because it's a protected directory. So sudo, I'll edit this in VM. I'm going to call this clean-pkg-cache.hook. So clean package cache .hook. And then what I'm going to do is I'm just going to do a paste. And you guys can see exactly what's going on here. I'm going to do a space there just to make this a little cleaner here. So the trigger this time is three different operations. So anytime there's an upgrade, anytime a package is installed, anytime a package is removed. And the target for the packages is just an asterisk, meaning I don't care what you're installing or removing. Anytime you're basically run anything with pac-man, I want you to run the following action. And I want you to execute pac-cache-ar. Now I gave the full path to the pac-cache binary slash user slash bin slash pac-cache dash r. And let me write and quit that. And now anytime I do a pac-man syu, as long as there's a package that actually has to update or install something or remove something, it should run that pac-cache hook for us and keep us from having that situation where we've got a lot of extra cruft just hanging around on the system as far as that cache database. Now before I go, I want to thank a few special people. I want to thank the producers of this episode. Devin Gabe James, Maxim Matt Michael, Mitchell Paul Scott, Wes Allen, Armoredragon, Chuck Manderangri, Diochai, Dylan George, Lidl, and Ex-Ninja Mike, Erion, Alexander, Peace, Artem, Fedora, Polytech, Realiteats4Less, Red Prophet, Steven and Willie, these guys. They're my highest-eared patrons over on Patreon. These guys, they're the producers of this show. I also want to thank each and every one of these fine ladies and gentlemen, all these names you're seeing on the screen right now. These are all my supporters over on Patreon, because I don't have any corporate sponsors. I'm sponsored by you guys, the community. You want to see more videos about Linux and free and open source software, pac-man hooks, and stuff like that nerdy stuff. Support DistroTube over on Patreon. Alright guys, peace. I should create a pac-man hook that plays pac-man arcade sounds when I do an upgrade.