command-not-found v0.3 (18.04.5-1) crashed
Open, Needs TriagePublic

Description

When entering a command which is not available, command-not-found should tell the package where the command might be part of.
Instead, it crashed with error message:

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.6.7 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/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

Running update-command-not-found as root doesn't help. The *.db Files in /var/cache/command-not-found are outdated (last modified in July).

The package command-not-found was updated today on my system from 0.2.38-4 to 18.04.5-1.

hethi created this task.Nov 29 2018, 10:02 AM

I assume that building the database failed (though update-command-not-found didn't issue any message), as /var/lib/command-not-found is empty, which seems to be the (new?) place of the database (according to `/usr/share/command-not-found/CommandNotFound/CommandNotFound.py).

The path /var/cache/command-not-found doesn't belong to any package anymore (according to dpkg -S /var/cache/command-not-found); should'nt it be removed during upgrade? There was a warning in the upgrade message (stored in /var/log/apt/term.log):

Preparing to unpack .../00-command-not-found_18.04.5-1_all.deb ...
Unpacking command-not-found (18.04.5-1) over (0.2.38-4) ...
dpkg: warning: unable to delete old directory '/var/cache/command-not-found': Directory not empty
...
Setting up command-not-found (18.04.5-1) ...
Installing new version of config file /etc/zsh_command_not_found ...
You need to run 'update-command-not-found' as root to update the cache.

Updating the command not found database didn't work as there are no Contents files (/var/lib/apt/lists/*Contents*) which are required by update-command-not-found.

The tool should issue some hint if there are no contents files, though.

hethi added a project: Restricted Project.Nov 29 2018, 10:48 AM
Wayne added a subscriber: Wayne.Nov 29 2018, 1:51 PM
bwana added a subscriber: bwana.Jan 20 2019, 10:19 AM

Is there a workaround or manual way to fix this issue in the meantime?

hethi added a comment.Jan 22 2019, 8:03 PM

If you add e.g. Debian to the apt sources, e.g. cause you need some Debian non-free package which of course is a bad bad bad thing on PureOS, you get some Contents files which were mentioned above - then a commands.db will be created, but for these Contents files only. I.E. the command-not-found will tell you Debian packages only which contain the searched command, but not PureOS packages. Not really what you want.

Thank you @hethi , I opted to remove command-not-found until there's an update to fix its behavior. For anyone who may come across this issue and would like to remove it:

sudo apt remove command-not-found

Now I just get {command_name}: command not found when I type an invalid one in.

louis added a subscriber: louis.May 31 2019, 7:57 PM

This bug was also reported on the debian bug tracking system https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=927338

I opened a Merge Request on debian's GitLab repo for the project to fix the unbound variable, but no review from the maintainer so far.

The program being unable to build its database is still a problem though.

louis added a comment.EditedFri, Aug 23, 2:30 PM

Still no update from the command-not-found repo, and no progress on T638 so far, so I guess removing command-not-found altogether is the best solution for now 🤷

Add Comment