一、问题描述
正如前一篇博客展示的那样,服务器环境有点乱乱的,这不,第二个异常点就来了。笔者准备使用vmtouch
命令,系统居然和我这样说:
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.3 LTS
Release: 20.04
Codename: focal
Exception information:
......
看起来是系统找不到vmtouch
命令,调用command-not-found
时又出了问题。
二、解决方案
去因特耐特找寻问题答案,有人[1]说是编码有问题,并给出了几行命令,但是笔者尝试过后发现并没有什么变化,但还是附命令如下(诸位判断清楚自己遇到问题的真正原因再执行命令):
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
sudo locale-gen en_US.UTF-8
sudo dpkg-reconfigure locales
之后笔者在StackOverflow[2]找到了和我问题类似的贴子,解决方案如下。
一位名为Sajjad Ahmad
的用户这样描述:
If any of the above solutions don't work, it means "command-not-found" utility itself is misconfigured.
Simply remove the utility, and install again.
如果上述任何解决方案都不起作用,则表示“command-not-found”程序本身配置错误。
只需删除该程序,然后再次安装。
上述解决方案指[1]。
对我有用的解决步骤为:
-
删除
command-not-found
程序,执行sudo apt purge command-not-found
输出如下:Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: gir1.2-snapd-1 libextutils-depends-perl python3-dateutil python3-debconf python3-requests-unixsocket python3-yaml software-properties-common update-notifier-common Use 'sudo apt autoremove' to remove them. The following packages will be REMOVED: command-not-found* 0 upgraded, 0 newly installed, 1 to remove and 1274 not upgraded. After this operation, 27.6 kB disk space will be freed. Do you want to continue? [Y/n] Y (Reading database ... 260108 files and directories currently installed.) Removing command-not-found (0.3ubuntu16.04.2) ... (Reading database ... 260102 files and directories currently installed.) Purging configuration files for command-not-found (0.3ubuntu16.04.2) ...
看起来删除成功了。
-
再次安装
command-not-found
程序,执行sudo apt install command-not-found
输出如下:Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: command-not-found : Depends: python3-commandnotfound (= 18.04.6) but 20.04.2 is to be installed E: Unable to correct problems, you have held broken packages.
看起来又出现了依赖问题,依赖低版本但是已经安装了高版本,参考我的博客,老解决方法,我直接
remove
。 -
执行
sudo apt remove python3-commandnotfound
,提示如下:Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: gir1.2-snapd-1 libextutils-depends-perl python3-dateutil python3-debconf python3-requests-unixsocket python3-yaml software-properties-common update-notifier-common Use 'sudo apt autoremove' to remove them. The following packages will be REMOVED: python3-commandnotfound sessioninstaller 0 upgraded, 0 newly installed, 2 to remove and 1274 not upgraded. After this operation, 297 kB disk space will be freed. Do you want to continue? [Y/n] Y (Reading database ... 260101 files and directories currently installed.) Removing sessioninstaller (0.20+bzr150-0ubuntu4.1) ... Removing python3-commandnotfound (20.04.2) ... Processing triggers for man-db (2.7.5-1) ...
-
重新安装command-not-found,执行
sudo apt install command-not-found
输出如下:Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: gir1.2-snapd-1 libextutils-depends-perl python3-dateutil python3-debconf python3-requests-unixsocket python3-yaml software-properties-common update-notifier-common Use 'sudo apt autoremove' to remove them. The following additional packages will be installed: command-not-found-data python3-commandnotfound The following NEW packages will be installed: command-not-found python3-commandnotfound The following packages will be upgraded: command-not-found-data 1 upgraded, 2 newly installed, 0 to remove and 1273 not upgraded. Need to get 1,023 kB of archives. After this operation, 1,112 kB disk space will be freed. Do you want to continue? [Y/n] Y Get:1 http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 command-not-found-data amd64 18.04.6 [1,009 kB] Get:2 http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 python3-commandnotfound all 18.04.6 [9,032 B] Get:3 http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 command-not-found all 18.04.6 [5,208 B] Fetched 1,023 kB in 4s (235 kB/s) (Reading database ... 260067 files and directories currently installed.) Preparing to unpack .../command-not-found-data_18.04.6_amd64.deb ... Unpacking command-not-found-data (18.04.6) over (0.3ubuntu16.04.2) ... Selecting previously unselected package python3-commandnotfound. Preparing to unpack .../python3-commandnotfound_18.04.6_all.deb ... Unpacking python3-commandnotfound (18.04.6) ... Selecting previously unselected package command-not-found. Preparing to unpack .../command-not-found_18.04.6_all.deb ... Unpacking command-not-found (18.04.6) ... Setting up command-not-found-data (18.04.6) ... Setting up python3-commandnotfound (18.04.6) ... Setting up command-not-found (18.04.6) ...
安装成功,测试一下,可以看到能够正确提示缺少的包:
root@ln01:/home/tangjiahao# testcommand testcommand: command not found root@ln01:/home/tangjiahao# vmtouch Command 'vmtouch' not found, but can be installed with: apt install vmtouch root@ln01:/home/tangjiahao#
问题解决
三、总结
以上就是今天要分享的内容,本文介绍了如何以重装command-not-found解决Sorry, command-not-found has crashed
提示的问题。另外vmtouch
是个用于了解和控制 unix 和类 unix 系统的文件系统缓存的工具,有机会讲一下如何使用(挖坑😬)。
如果本文能给你带来帮助的话,点个赞鼓励一下作者吧!💪
四、引用参考
[1] 关于ubuntu上执行错误命令报错:http://www.javashuo.com/article/p-uekwrird-n.html
[2] command not found message:https://stackoverflow.com/questions/19873430/command-not-found-message-when-i-try-to-add-command-in-bashrc
[3] vmtouch:https://github.com/hoytech/vmtouch