Ugh, this has bugged me for years. Like a number of other people, I HATE PackageKit and have gone out of my way to shut it down. I've also found you can't just uninstall it without significant ramifications. The best you can do is disable and mask it's systemctl service which keeps it from suddenly downloading copious amounts of packages onto your already full hard-drive. Rather I rely solely on command-line DNF to take care of any package and system upgrades.
So, I've generally just lived with this "annoying feature" each time I fat-finger a command such as 'mkae' (that's "make" for those that can type correctly).
Not being one to usually just give up and live with an annoyance like this, I finally took the time today to dig into it... I had realized that this has to be a feature coming from bash. But, I couldn't fathom that Fedora would tweak bash that much for PackageKit. But, I also couldn't really find any results searching on this topic (though I did find lots of other people who also seem annoyed with PackageKit, so apparently I am not alone). I was momentarily excited when I found this post, but only to quickly become disappointed by the lack of any answer!
So, I dug into it. I do know bash fairly well and decided to start by just searching the man page. And that ultimately led to this simple answer...
It turns out bash (and some other shells like zsh) have a
command_not_found_handle function that can be called when an arbitrary command is not found. Well, it turns out that PackageKit installs a file under /etc/profile.d which defines this function. It's
Looking at the version of the function in there yields a couple of different ways it could be disabled:
- You could just remove the /etc/profile.d/PackageKit.sh (though it likely would show back up on a package update).
- Remove executable permission from
/usr/libexec/pk-command-not-found (again, probably get reverted on a package update).
- Remove (or rename) the directory
/usr/libexec/packagekitd (and again, probably get re-installed on a package update).
unset -f command_not_found_handle to your local .bashrc file
- Lastly, define your own super awesome, "custom" function for
command_not_found_handle in your local .bashrc file (like mentioned in the comment above). I had started down that path, but then decided good old "command not found" was probably best...
Since, I've had so many issues when I tried to fully remove PackageKit, I've just had to leave it in place and keep it disabled & masked. As a result, I took the simplest approach of just unsetting the function in my local .bashrc and have now been very pleased with no longer seeing the stupid and obnoxious