Debian 命令未找到错误 - 分配前引用了局部变量“cnf”

Aru*_*ius 1 debian bugs

全新安装 Debian buster 操作系统和软件包后:command-not-found

运行命令:

$ curl
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: Debian
Description:    Debian 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
Run Code Online (Sandbox Code Playgroud)

update-command-not-found以 root 身份发布并不能解决问题。有错误报告,但似乎还没有修复。

Aru*_*ius 6

不直观,但错误立即消失apt update

# apt update
Hit:1 http://deb.debian.org/debian buster InRelease
Get:2 http://deb.debian.org/debian buster-updates InRelease [49.3 kB]
Hit:3 http://security.debian.org/debian-security buster/updates InRelease
Get:4 http://deb.debian.org/debian buster/main amd64 Contents (deb) [36.1 MB]
Get:5 http://deb.debian.org/debian buster-updates/main amd64 Contents (deb) [42.3 kB]
Fetched 36.2 MB in 7s (5,009 kB/s)                                                                                                                                    
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.

# curl

Command 'curl' not found, but can be installed with:

apt install curl
Run Code Online (Sandbox Code Playgroud)

附注。对于那些好奇的人,全新安装时缺少 db 的原因是:

ls -l /var/lib/command-not-found
total 0
Run Code Online (Sandbox Code Playgroud)

之后apt update我们有:

ls -l /var/lib/command-not-found
total 2504
-rw-r--r-- 1 root root 2560000 Jul 29 12:34 commands.db
-rw-r--r-- 1 root root     983 Jul 29 12:34 commands.db.metadata
Run Code Online (Sandbox Code Playgroud)