3

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 # 
7

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,
}
2

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.

  • Are you sure you do not have to also update the repository for the Raspbian kernel and drivers in /etc/apt/sources.list.d/raspi.list? – Ingo Mar 13 at 11:35
  • @Ingo I did that as well but the problem still persisted. – iBug Mar 13 at 11:40

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.