运行 Debian 的 Beaglebone Black 上的语言环境被破坏

Chr*_*ris 2 linux debian locale arm beaglebone

这一切都是从我想在运行 Debian 的 Beaglebone Black 上安装自定义守护进程开始的,update-rc.d mydaemon defaults 97就像我在 Mint 主机上开发过程中多次做过的那样。迎接我的是:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
   LANGUAGE = (unset),
   LC_ALL = (unset),
   LC_PAPER = "es_CL.UTF-8",
   LC_ADDRESS = "es_CL.UTF-8",
   LC_MONETARY = "es_CL.UTF-8",
   LC_NUMERIC = "es_CL.UTF-8",
   LC_TELEPHONE = "es_CL.UTF-8",
   LC_IDENTIFICATION = "es_CL.UTF-8",
   LC_MEASUREMENT = "es_CL.UTF-8",
   LC_NAME = "es_CL.UTF-8",
   LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
update-rc.d: using dependency based boot sequencing
Run Code Online (Sandbox Code Playgroud)

我随后尝试用 修复它dpkg-reconfigure locales,它回复了

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_PAPER = "es_CL.UTF-8",
    LC_ADDRESS = "es_CL.UTF-8",
    LC_MONETARY = "es_CL.UTF-8",
    LC_NUMERIC = "es_CL.UTF-8",
    LC_TELEPHONE = "es_CL.UTF-8",
    LC_IDENTIFICATION = "es_CL.UTF-8",
    LC_MEASUREMENT = "es_CL.UTF-8",
    LC_NAME = "es_CL.UTF-8",
    LANG = "en_US.UTF-8"
     are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
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
/usr/bin/locale: Cannot set LC_CTYPE to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_MESSAGES to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_ALL to default locale: No such file or directory
Generating locales (this might take a while)...
  en_US.ISO-8859-1...locale alias file `/usr/share/locale/locale.alias' not found: No such file or directory
 done
Generation complete.
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_MONETARY = "es_CL.UTF-8",
    LC_ADDRESS = "es_CL.UTF-8",
    LC_TELEPHONE = "es_CL.UTF-8",
    LC_NAME = "es_CL.UTF-8",
    LC_MEASUREMENT = "es_CL.UTF-8",
    LC_IDENTIFICATION = "es_CL.UTF-8",
    LC_NUMERIC = "es_CL.UTF-8",
    LC_PAPER = "es_CL.UTF-8",
    LANG = "C"
     are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_MONETARY = "es_CL.UTF-8",
    LC_ADDRESS = "es_CL.UTF-8",
    LC_TELEPHONE = "es_CL.UTF-8",
    LC_NAME = "es_CL.UTF-8",
    LC_MEASUREMENT = "es_CL.UTF-8",
    LC_IDENTIFICATION = "es_CL.UTF-8",
    LC_NUMERIC = "es_CL.UTF-8",
    LC_PAPER = "es_CL.UTF-8",
    LANG = "C"
     are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Run Code Online (Sandbox Code Playgroud)

我不知道如何解决这个问题,因为它拒绝让我安装任何软件包或更新任何内容......有人有任何想法吗?我很困惑...

ps 我在 Debian 上看到过配置区域设置,但这对我不起作用(即source /etc/default/locale

pps 我还检查了/etc/locales.genshell,并且en_US.UTF-8 UTF-8没有注释,因为它应该是,并且 shell 脚本建议运行locale-gen,我得到

Generating locales (this might take a while)...
en_US.UTF-8...locale alias file `/usr/share/locale/locale.alias' not found: No such file or directory
Run Code Online (Sandbox Code Playgroud)

Chr*_*ris 5

因此,在浏览了所有 Debian 手册和 BeagleBone 构建之后,我终于弄清楚发生了什么!我想我会把它贴出来以防有人遇到这个问题。为了修复区域设置,我需要手动重写文件/etc/default/locale:(例如,如果您在北美,您将使用“en_US.UTF-8”)。

LANG="en_US.UTF-8"
LC_NUMERIC="es_CL.UTF-8"
LC_MONETARY="es_CL.UTF-8"
LC_PAPER="es_CL.UTF-8"
LC_NAME="es_CL.UTF-8"
LC_ADDRESS="es_CL.UTF-8"
LC_TELEPHONE="es_CL.UTF-8"
LC_MEASUREMENT="es_CL.UTF-8"
LC_IDENTIFICATION="es_CL.UTF-8"
Run Code Online (Sandbox Code Playgroud)

然后,您需要确保 shell 脚本/etc/locale.gen具有您打算使用的所有区域设置(未注释)sudo nano /etc/locale.gen

然后,您需要修复区域设置所需的符号链接,即内核应在安装时创建的符号链接,这是通过以下方式完成的:sudo ln -s /etc/locale.alias /usr/share/locale/locale.alias

最后运行dpkg-reconfigure locales以修复链接,现在一切都应该运行良好。

(旁注:我后来意识到这update-rc.d是 Debian 后续版本上的遗留工具,例如 BeagleBone black 上的工具,应该使用守护进程 shell 来安装insserv mydaemon