7

I just updated my Raspbian to Buster (testing) by editing /etc/apt/sources.list and replacing all stretch with buster and doing apt update && apt dist-upgrade. Now apt update always shows an error when updating CommandNotFound database, as well as manually running update-command-not-found as root. How can I get rid of this error?

root@raspberrypi:/home/pi # update-command-not-found
Traceback (most recent call last):
  File "/usr/sbin/update-command-not-found", line 26, in <module>
    col.create(db)
  File "/usr/share/command-not-found/CommandNotFound/db/creator.py", line 94, in create
    self._fill_commands(con)
  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'
root@raspberrypi:/home/pi # echo $?
1
root@raspberrypi:/home/pi # 
iBug
  • 315
  • 2
  • 14

2 Answers2

10

Dirty Fix:

Add a line of 'rpi': 10, to the end of list component_priorities in /usr/share/command-not-found/CommandNotFound/db/creator.py.

Result should like this:

component_priorities = {
    'main': 120,
    'universe': 100,
    'contrib': 80,
    'restricted': 60,
    'non-free': 40,
    'multiverse': 20,
    'rpi': 10,
}
CzBiX
  • 116
  • 3
3

Look at the Python traceback, I located the line that caused the error at line 271 of file /usr/share/command-not-found/CommandNotFound/db/creator.py. I opened that file and replaced the line with

priority = component_priorities.get(component)

and ran update-command-not-found again, and it completed without problems.

iBug
  • 315
  • 2
  • 14