I'm trying to get command-not-found package to work. That's the one which tells what to install when the user types a missing command, for instance:

$ zbarcam
The program 'zbarcam' is currently not installed. You can install it by typing:
sudo apt-get install zbar-tools

However, when I try to set it up, I get the following error

$ sudo update-command-not-found 
Traceback (most recent call last):
File "/usr/sbin/update-command-not-found", line 26, in <module>
File "/usr/share/command-not-found/CommandNotFound/db/creator.py", line 94, in create
File "/usr/share/command-not-found/CommandNotFound/db/creator.py", line 132, in _fill_commands
self._parse_single_contents_file(con, f, fp.stdout)
File "/usr/share/command-not-found/CommandNotFound/db/creator.py", line 271, in _parse_single_contents_file
priority = component_priorities[component]
KeyError: 'rpi'

I'm pretty certain I don't have anything non-standard in apt sources, and the issue seems to come from the rpi component which is indeed in the default sources.list:

deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi

Is there any way to get it to work, preferably without removing the rpi component?

2 Answers 2


I tried to install command-not-found on Raspbian Buster with:

pi@rasberrypi:~ $ sudo apt install command-not-found

It succeeds without error messages. After a reboot I get:

pi@rasberrypi:~ $ zbarcam 
Could not find the database of available applications, run update-command-not-found as root to fix this
Sorry, command-not-found has crashed! Please file a bug report at:
Please include the following information with the report:

command-not-found version: 0.3
Python version: 3.7.3 final 0
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 10 (buster)
Release:    10
Codename:   buster
Exception information:

local variable 'cnf' referenced before assignment
Traceback (most recent call last):
  File "/usr/share/command-not-found/CommandNotFound/util.py", line 23, in crash_guard
  File "/usr/lib/command-not-found", line 93, in main
    if not cnf.advise(args[0], options.ignore_installed) and not options.no_failure_msg:
UnboundLocalError: local variable 'cnf' referenced before assignment

pi@raspberrypi:~ $ sudo update-command-not-found
pi@raspberrypi:~ $

I get another result then you. update-command-not-found succeeds without errors but executing zbarcam gives always the same error as shown. So you should file a bug as suggested.


Update 2019sep09hkt2238

(1) I ran "$ sudo apt-get install command-not-found" and got message saying OK, blah, blah, blah, version 18.04.5-1.

(2) "$ sudo update-command-not-found" returns nothing. I guess it means no update to do.

(3) I don't understand the "rpi" component thing. I read that there are 3 packages.

(4) I don't know what is "sources.list", and how to check if "rpi" is in that list. Perhaps you can give me a bash statement to do that. PS - I don't know how to use the weird "grep" thing. In other words, I am a linux newbie.

(5) Actually I don't even know what actually is the thing "repositories". I guess it is a collection of warehouses storing millions of packages. :)

Wrong Answer to delete later

Yes, I could not install blah-utils in terminal mode, so I tried it in desktop and found it OK. I can run blah now but don't know how to do the database thing. :)

Blah running log tlfong01 2019sep09hkt1544

  • Did sudo update-command-not-found run OK? Commented Sep 9, 2019 at 7:55
  • I didn't try that. I only tried to install blah-utils but no luck, so I gave up and switched to desktop. Just now I tried "$ sudo update-command-not-found" and found no error message.
    – tlfong01
    Commented Sep 9, 2019 at 8:09
  • I'm not sure it that was clear, but blah-utils is not a real package, I just made it up as an example. Of course, that doesn't explain the crashing in your log. Commented Sep 9, 2019 at 8:50
  • 1
    Oh my goodness. So I got it all wrong. I wrongly thought that "blah" was a real command. I know what is three blahs "blah blah blah" but not one "blah". If you used "foo", perhaps I won't misunderstand. Actually when I first met the word "foo" I thought it was a real thing. I was never sure if it is "fool" in short. It is only when I googled servers yesterday that I learned why Apache server is called Apache. I am glad that I have a good English lesson today.
    – tlfong01
    Commented Sep 9, 2019 at 9:01
  • Sorry for that. I fixed the question to hopefully avoid confusion. In any case, that rpi component seems to break command-not-found, which otherwise works for me. Since it's only 3 packages, I suppose I can live without it for a while. Commented Sep 9, 2019 at 9:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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