i've also hit the problem on fresh install.
and the problem here was not because of permissions, but that database
just does not exist.
and running update-command-not-found that the initial message suggests,
does not work, because the script expects /var/lib/apt/lists/*Contents*
to exist. which i did not
```
root@acai /etc/sudoers.d# getgid
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:
http://www.debian.org/Bugs/Reporting
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
callback()
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
```
the command does absolutely nothing if apt db not present:
```
root@acai /etc/sudoers.d# update-command-not-found --verbose --debug
root@acai /etc/sudoers.d#
```
finally running apt update yields again error
```
root@acai /etc/sudoers.d# apt update
Get:3 http://archive.raspberrypi.org/debian buster InRelease [25.1 kB]
Get:4 http://raspbian.raspberrypi.org/raspbian buster InRelease [15.0 kB]
Get:5 http://raspbian.raspberrypi.org/raspbian buster/main armhf
Packages [13.0 MB]
Get:6 http://archive.raspberrypi.org/debian buster/main armhf Packages
[234 kB]
Get:7 http://archive.raspberrypi.org/debian buster/main armhf Contents
(deb) [961 kB]
Get:8 http://raspbian.raspberrypi.org/raspbian buster/main armhf
Contents (deb) [39.8 MB]
Get:9 http://raspbian.raspberrypi.org/raspbian buster/contrib armhf
Contents (deb) [211 kB]
Get:10 http://raspbian.raspberrypi.org/raspbian buster/non-free armhf
Contents (deb) [780 kB]
Get:11 http://raspbian.raspberrypi.org/raspbian buster/rpi armhf
Contents (deb) [328 B]
Traceback (most recent call last):
File "/usr/lib/cnf-update-db", line 26, in
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'
Reading package lists... Done
E: The repository 'http://glen.alkohol.ee/okas/dist ./ Release' does not
have a Release file.
N: Updating from such a repository can't be done securely, and is
therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user
configuration details.
E: Problem executing scripts APT::Update::Post-Invoke-Success 'if
/usr/bin/test -w /var/lib/command-not-found/ -a -e
/usr/lib/cnf-update-db; then /usr/lib/cnf-update-db > /dev/null; fi'
E: Sub-process returned an error code
```
the command itself invoked gives:
```
root@acai /etc/sudoers.d# update-command-not-found --verbose
Traceback (most recent call last):
File "/usr/sbin/update-command-not-found", line 26, in
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'
```