12

我问了一个关于如何在 bash shell 中编写精美优雅的 linux 命令的问题

当我尝试这个建议时,我收到了以下错误消息。

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.2.3 final 0
Distributor ID: Ubuntu
Description:    Ubuntu 12.10
Release:    12.10
Codename:   quantal
Exception information:

unsupported locale setting
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/CommandNotFound/util.py", line 24, in crash_guard
    callback()
  File "/usr/lib/command-not-found", line 69, in main
    enable_i18n()
  File "/usr/lib/command-not-found", line 40, in enable_i18n
    locale.setlocale(locale.LC_ALL, '')
  File "/usr/lib/python3.2/locale.py", line 541, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

这是我目前在我的 .bashrc 中写的

source .bashrc
export LC_CTYPE="utf-8"
function go_app() { cd /var/virtual/$1/; }

这是我的 /var/www 目录

www-data@ubuntu:~$ ls -la
total 52
drwxr-xr-x  5 www-data www-data  4096 Nov  9 15:03 .
drwxr-xr-x 15 root     root      4096 Nov  8 09:51 ..
-rw-------  1 www-data www-data 19657 Nov  7 23:24 .bash_history
-rwxr-xr-x  1 www-data www-data    82 Nov  9 15:03 .bashrc
drwx------  2 www-data www-data  4096 Aug  7 19:28 .cache
drwxrwxr-x  3 www-data www-data  4096 Aug  9 19:19 .composer
-rw-------  1 www-data www-data     6 Aug  8 11:48 .mysql_history
-rw-------  1 root     root        50 Nov  9 15:08 .nano_history
drwxrwxr-x  2 www-data www-data  4096 Aug  7 20:19 .ssh

编辑:

新的.bashrc

export LC_CTYPE="en_US.utf8"
function go_app() { cd /var/virtual/$1/; }

错误信息:

go_app: command not found
4

5 回答 5

22

糟糕的 WSL 升级弄乱了我的一些文件权限。上述任何事情都不适合我,但这确实:

sudo chmod o+r /var/lib/command-not-found/commands.db
于 2020-10-04T14:36:19.783 回答
9

这应该可以解决“抱歉,command-not-found has crashed!...”问题:

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 required on ubuntu 20.04
sudo dpkg-reconfigure locales
于 2014-11-17T15:42:41.567 回答
4

如果上述任何解决方案都不起作用,则意味着“command-not-found”实用程序本身配置错误。

只需删除该实用程序,

sudo apt purge command-not-found

并再次安装,

sudo apt install command-not-found
于 2020-05-09T14:51:49.500 回答
3

最后一个星号会更好:

sudo chmod o+r /var/lib/command-not-found/commands.db*
>----------------------------------------------------^
于 2020-11-17T21:19:39.197 回答
1

您是否尝试过更改export LC_CTYPE="utf-8"export LC_CTYPE="en_US.utf8"? 后者在我的系统上引用了一个有效的语言环境名称。您可以通过运行来查看系统上的有效语言环境名称locale -a

于 2013-11-09T07:35:38.697 回答