首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Debian命令-找不到错误-局部变量“cnf”在赋值前引用。

Debian命令-找不到错误-局部变量“cnf”在赋值前引用。
EN

Unix & Linux用户
提问于 2020-05-07 09:47:22
回答 2查看 1.6K关注 0票数 4

重新安装Debian buster操作系统和软件包后:命令未找到

运行命令:

代码语言:javascript
复制
$ 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

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

EN

回答 2

Unix & Linux用户

回答已采纳

发布于 2020-05-07 09:47:22

不直观,但错误在apt update之后立即消失:

代码语言:javascript
复制
# 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

PS。对于那些好奇的人来说,新安装时缺少db的原因是:

代码语言:javascript
复制
ls -l /var/lib/command-not-found
total 0

apt update之后,我们有:

代码语言:javascript
复制
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
票数 10
EN

Unix & Linux用户

发布于 2021-01-16 07:51:26

更改权限

代码语言:javascript
复制
sudo chmod o+r /var/lib/command-not-found/commands.db*

但在那之前

检查权限变量状态信息

代码语言:javascript
复制
ls -l /var/lib/command-not-found

total 2588

-rw-r----- 1 root root 2834432 Dec 18 05:25 commands.db
-rw-r----- 1 root root    4712 Dec 18 05:25 commands.db.metadata

它应该是:

代码语言:javascript
复制
ls -l /var/lib/command-not-found

total 2588

-rw-r--r-- 1 root root 2641920 Jan 16 00:27 commands.db
-rw-r--r-- 1 root root    1175 Jan 16 00:27 commands.db.metadata
票数 3
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/585107

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档