Ubuntu 20.04 の command-not-found
が動かなくなってた.
いつからか不明.
$ /usr/lib/command-not-found emacs
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.8.10 final 0
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal
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
直接の原因はパッケージ検索のためのDBファイルに読み取り権限がついていないことだと思う.
$ ls -l /var/lib/command-not-found/
total 3096
-rw------- 1 root root 3162112 Jul 25 22:36 commands.db
-rw------- 1 root root 3306 Jul 25 22:36 commands.db.metadata
なので, 読み取り権限を与えてやれば動くようにはなる.
$ sudo chmod o+r /var/lib/command-not-found/commands.db 3.7m
$ /usr/lib/command-not-found emacs
Command 'emacs' not found, but can be installed with:
sudo snap install emacs # version 27.2, or
sudo apt install e3 # version 1:2.71-2
sudo apt install emacs-gtk # version 1:26.3+1-1ubuntu2
sudo apt install emacs-lucid # version 1:26.3+1-1ubuntu2
sudo apt install emacs-nox # version 1:26.3+1-1ubuntu2
sudo apt install jove # version 4.17.2.7-1
See 'snap info emacs' for additional versions.
でもなぜ?