为什么即使设置了区域设置错误?

why do I get a locale error even though it is set?

当我 运行 bitbake 时,我得到以下信息:

$ bitbake core-image-base
Please use a locale setting which supports utf-8.
Python can't change the filesystem locale after loading so we need a utf-8 when python starts or things won't work.

即使我的语言环境设置为 en_US.UTF-8,这是为什么?

$ echo $LC_ALL
en_US.UTF-8

有关其他背景信息,另请参阅https://unix.stackexchange.com/questions/626916/how-to-set-locale-correctly-manually/626919

更新:

$ locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LANGUAGE=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8

我的 ~/.bashrc 看起来像:

$ cat ~/.bashrc
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8

打开新的 shell 我得到:

$ bash
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

如果 shell 在您添加语言环境之前存在,那么您需要打开一个新的(运行 bash 作为 child,打开一个新的终端,正在执行新的 ssh,...)

那么这应该可以工作。

$ export LC_ALL="en_US.UTF-8"
$ bitbake core-image-base

可能不需要导出,这取决于您系统的默认设置。

将“评论加冕成功”作为答案:

sudo locale-gen en_US en_US.UTF-8
sudo dpkg-reconfigure locales