1

I have uninstall PackageKit on Fedora, because I didn't need the bloat & race-conditions with the command-line.

Since then, command-not-found fails with the following:

❯ foo
bash: foo: command not found...
Failed to search for file: GDBus.Error:org.freedesktop.DBus.Error.NameHasNoOwner: Could not activate remote peer.
# because...
❯ dbus-send --system --print-reply  --dest=org.freedesktop.PackageKit  \
    /org/freedesktop/PackageKit org.freedesktop.DBus.Properties.Get  \  
    string:'org.freedesktop.PackageKit' string:'BackendName'

Error org.freedesktop.DBus.Error.NameHasNoOwner: Could not activate remote peer.

How can I retain command-not-found functionality without PackageKit? It seems dnf should be able to handle that on its own?

Versions:

  • Fedora 31 beta + gnome-shell 3.34.0 + zsh 5.7.1
  • PackageKit-command-not-found-1.1.12-11.fc31.x86_64.rpm
  • 1
    Do you want dnf to search for available packages or just display "Command not found"? You should be able to achieve either with this: unix.stackexchange.com/questions/208369/… It's a workaround though. The original command_not_found_handle should check if PackageKit is there. You could file a bugreport. – rudib Sep 29 '19 at 15:06
3

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 /etc/profile.d/PackageKit.sh

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).
  • Add 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 GDBus.Error:org.freedesktop.DBus.Error.NameHasNoOwner error.

HTH!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.