Fedora Command Not Found – Fixing Fedora’s Command-Not-Found

bashfedoralinuxpackage-managementyum

I've recently installed Fedora 19. Packagekit-command-not-found is installed. But its own examples don't work. When I enter gedti the output is:

bash: gedti: command not found... Similar command is: 'gedit'

And it works correctly but when I enter powertop, the output is:

bash: powertop: command not found...

With no suggestion about the package. Why? Should I edit some configuration files or update some cache or … ?

Best Answer

There is definitely some weirdness with PackageKit. I already had powertop installed but wanted to test out what you're having issues with.

$ rpm -ql PackageKit-command-not-found
/etc/PackageKit/CommandNotFound.conf
/etc/profile.d/PackageKit.sh
/usr/libexec/pk-command-not-found

So from the above you can run the command that PackageKit will run to do the search like so:

$ /usr/libexec/pk-command-not-found <command>

Example

$ /usr/libexec/pk-command-not-found powertop
bash: powertop: command not found...

$ which powertop
/usr/bin/powertop

Running it a 2nd time I got it to recommend powertop:

$ /usr/libexec/pk-command-not-found powertop
bash: powertop: command not found...
Install package 'powertop' to provide command 'powertop'? [N/y] 

So why isn't it finding powertop?

I think that ultimately the root cause is the timeout that's defined in the config file: /etc/PackageKit/CommandNotFound.conf:

MaxSearchTime=2000

This timeout is to cap how long PackageKit will take to do it's query. The query is not against your local Yum cache, it's searching live against Yum repositories that you have configured on the internet. Therefore if you want it to be more thorough vs. more performant you have the following trade-off:

# aggressive find
MaxSearchTime=15000

# more responsive
MaxSearchTime=250    
Related Question