command-not-found has crashed

Bug #1933704 reported by Robert
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
command-not-found
New
Undecided
Unassigned

Bug Description

robert@saaz:~$ s
Sorry, command-not-found has crashed! Please file a bug report at:
https://bugs.launchpad.net/command-not-found/+filebug
Please include the following information with the report:

command-not-found version: 0.3
Python version: 3.9.5 final 0
Distributor ID: Ubuntu
Description: Ubuntu 21.04
Release: 21.04
Codename: hirsute
Exception information:

unable to open database file
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/CommandNotFound/util.py", line 23, in crash_guard
    callback()
  File "/usr/lib/command-not-found", line 90, in main
    cnf = CommandNotFound.CommandNotFound(options.data_dir)
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 79, in __init__
    self.db = SqliteDatabase(dbpath)
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 12, in __init__
    self.con = sqlite3.connect(filename)
sqlite3.OperationalError: unable to open database file

So I tried reinstalling it:

robert@saaz:~$ sudo apt-get purge -f command-not-found
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
  command-not-found*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 36.9 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 560379 files and directories currently installed.)
Removing command-not-found (20.10.1) ...
(Reading database ... 560373 files and directories currently installed.)
Purging configuration files for command-not-found (20.10.1) ...
dpkg: warning: while removing command-not-found, directory '/var/lib/command-not-found' not empty so not removed

robert@saaz:~$ ls -la /var/lib/command-not-found/
total 3.2M
drwxr-xr-x 2 root root 4.0K 2021-06-25 00:27 .
drwxr-xr-x 102 root root 4.0K 2021-06-18 15:18 ..
-rw-r----- 1 root root 3.2M 2021-06-25 00:27 commands.db
-rw-r----- 1 root root 2.5K 2021-06-25 00:27 commands.db.metadata

...and removed the files that it left behind (shouldn't the uninstall step take care of this?):

robert@saaz:~$ sudo rm -rf /var/lib/command-not-found/

robert@saaz:~$ sudo apt-get install command-not-found
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  command-not-found
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/5,236 B of archives.
After this operation, 36.9 kB of additional disk space will be used.
Selecting previously unselected package command-not-found.
(Reading database ... 560371 files and directories currently installed.)
Preparing to unpack .../command-not-found_20.10.1_all.deb ...
Unpacking command-not-found (20.10.1) ...
Setting up command-not-found (20.10.1) ...

Then it looks like its post-install script is broken. At least I think it should set up command-not-found without me having to run another command.

robert@saaz:~$ s

Could not find command-not-found database. Run 'sudo apt update' to populate it.
s: command not found

robert@saaz:~$ sudo apt update
Hit:1 http://us.archive.ubuntu.com/ubuntu hirsute InRelease
Get:2 http://security.ubuntu.com/ubuntu hirsute-security InRelease [101 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu hirsute-updates InRelease [109 kB]
Get:4 http://ppa.launchpad.net/system76-dev/stable/ubuntu hirsute InRelease [17.5 kB]
Hit:5 http://archive.canonical.com/ubuntu hirsute InRelease
Hit:6 http://us.archive.ubuntu.com/ubuntu hirsute-backports InRelease
Get:7 http://us.archive.ubuntu.com/ubuntu hirsute-updates/main amd64 c-n-f Metadata [4,800 B]
Fetched 232 kB in 1s (295 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.

Now it's kind of installed... at least it doesn't crash anymore, but doesn't produce helpful output either:

robert@saaz:~$ s
s: command not found

Version information:
robert@saaz:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=21.04
DISTRIB_CODENAME=hirsute
DISTRIB_DESCRIPTION="Ubuntu 21.04"

I had the same issue a few days ago and reinstalling fixed it. Not sure why it got in that bad state again.

I've upgraded my system a few times from previous Ubuntu versions; maybe it's time to do a fresh installation.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.