Ubuntu 12.04 奇怪的语言环境行为

Ubuntu 12.04 奇怪的语言环境行为

我正在运行带有 Vagrant 的 Ubuntu 12.04。我很难理解我的系统上的语言环境出了什么问题。

当我通过 ssh 登录到我的盒子时

$ vagrant ssh

并尝试运行一些与语言环境相关的程序,我发现有些不对劲:

$ locale
locale: Cannot set LC_CTYPE 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=
LC_CTYPE=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=

或者例如

$ nonexistcmd
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.2.44

但是当我以同一个用户身份重新登录时,sudo su - vagrant一切都变得正常:

$ locale
LANG=en_US.UTF-8
LANGUAGE=
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=

vagrant@vagrant-ubuntu-precise-64:~$ nonexistcmd
nonexistcmd: command not found

怎么会这样?发生什么事了?

提前致谢!

附加信息:

$ cat /var/lib/locales/supported.d/local 
en_US.UTF-8 UTF-8

$ cat /etc/default/locale 
LANG="en_US.UTF-8"

答案1

我得到了它。

这不是服务器端的问题。是我的 MacOS SSH 客户端发送了一些与语言环境相关的环境变量(LANG、LC_*)。感谢救命的岗位

相关内容