通过 GUI 更改 Ubuntu 区域设置会导致帐户守护进程崩溃

通过 GUI 更改 Ubuntu 区域设置会导致帐户守护进程崩溃

我使用的是 Ubuntu 12.04,在自动更新后,它将系统默认编码从 UTF-8 更改为“ANSI_X3.4-1968”。我意识到当我在 Eclipse 中的代码注释出现奇怪的字符时,在意识到 IDE 没有问题后,我打开了一个终端进行检查。当我在终端窗口中输入拉丁字符(例如 çãõéèê...)时,会显示一个问号。当我“cat”文本文件时也是如此。通过 GUI 更改 Ubuntu 区域设置会导致帐户守护程序崩溃:

ExecutablePath: /usr/bin/gnome-language-selector
ProcCmdline: /usr/bin/python /usr/bin/gnome-language-selector
...
File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 651, in call_blocking      message, timeout)
DBusException: org.freedesktop.Accounts.Error.Failed: running '/usr/share/language-tools/save-to-pam-env' failed: no output

然后,我更改了 save-to-pam-env,添加了一个调试行,并在终端中执行了 lang-selector:

gag@desktop~> /usr/bin/python /usr/bin/gnome-language-selector
(gnome-language-selector:17733): Gtk-WARNING **: Locale not supported by C library.
    Using the fallback 'C' 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_COLLATE to default locale: No such file or directory
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LANG = "pt_BR"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
...same message a dozen times...
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
/usr/lib/python2.7/dist-packages/LanguageSelector/gtk/GtkLanguageSelector.py:858: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
  self._localeinfo.translate(loc, native=True) == defaultLangName):
  //the line below is my debug 'print'
  exec: /usr/share/language-tools/save-to-pam-env /home/likewise-open/CERTI/gag pt_BR.UTF-8 

因此,手动运行此命令:

gag@desktop~> /usr/share/language-tools/save-to-pam-env /home/likewise-open/CERTI/gag pt_BR.UTF-8
pt_BR.UTF-8
gag@ccd-7840~> locale
LANG=
LANGUAGE=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
gag@desktop~> cat .pam_environment 
LANGUAGE=en
LANG=en_US.UTF-8
LC_NUMERIC=pt_BR.UTF-8
LC_TIME=pt_BR.UTF-8
LC_MONETARY=pt_BR.UTF-8
LC_PAPER=pt_BR.UTF-8
LC_NAME=pt_BR.UTF-8
LC_ADDRESS=pt_BR.UTF-8
LC_TELEPHONE=pt_BR.UTF-8
LC_MEASUREMENT=pt_BR.UTF-8
LC_IDENTIFICATION=pt_BR.UTF-8

一切似乎都很好,但重新启动 PC 并重新登录后,情况仍然相同。通过 CLI,我可以看到语言环境已正确安装:

gag@desktop~> locale -a | grep pt
pt_BR.utf8
pt_PT.utf8
gag@desktop~> locale -m | grep UTF
UTF-8

我也尝试过:

sudo apt-get install language-pack-pt language-pack-pt-base
sudo apt-get install --reinstall locales

没有效果。当我用另一个帐户登录时,编码正常。有什么想法吗?

答案1

事实证明我的“~/.pam_environment”配置根本没有被读取。我通过在 ~/.profile 文件中设置这些来解决这个问题:

export LC_COLLATE="C"
export LANG="en_US.UTF-8"
export LC_ALL="pt_BR.UTF-8"

尽管在“区域设置”手册条目中不建议使用 LC_ALL。

我在 googli'n 上找到的导致 .pam_environment 被忽略的唯一原因是主目录。使用 ecryptfs 进行加密 - 但这不是我的情况。

不管怎样,它都在发挥作用,所以就这样吧。

相关内容