I’m trying to install a setup script for GCP for school, planning on uninstalling it afterwards :wink: I am getting a command not found error… right now I am running sudo apt-upgrade but I will post the full error message after.

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.2 final 0
Distributor ID: PureOS
Description: PureOS GNU/Linux 8
Release: 8
Codename: green
Exception information:

local variable ‘cnf’ referenced before assignment
Traceback (most recent call last):
File “/usr/share/command-not-found/CommandNotFound/”, 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

1 Like

Some others have reported this as well. I think the consensus is to just remove the command-not-found package. I believe sudo apt remove command-not-found will do it.

1 Like

Yep, as @taylor-williamc mentions, several have reported this. There are a couple of threads in this forum, but you may want to add yourself to this tracking item if you can.

I am one who removed the package; I have not seen ill effects (yet).

1 Like

All variable assignments in a function store the value in the local symbol table; whereas variable references first look in the local symbol table, then in the global symbol table, and then in the table of built-in names. Thus, global variables cannot be directly assigned a value within a function (unless named in a global statement), although they may be referenced.

The unboundlocalerror: local variable referenced before assignment is raised when you try to use a variable before it has been assigned in the local context. Python doesn’t have variable declarations , so it has to figure out the scope of variables itself. It does so by a simple rule: If there is an assignment to a variable inside a function, that variable is considered local .