apt-get 在 LC_NUMERIC 语言环境中失败

apt-get 在 LC_NUMERIC 语言环境中失败

我的系统无法使用“软件更新程序”、“ubuntu 软件”或命令行进行更新。

sudo apt-get upgrade返回大量文本(见下文)。我猜这部分可以识别问题:

/usr/sbin/update-info-dir: 2: /etc/environment: LC_NUMERIC: not found

如果我尝试,update-info-dir我会得到同样的错误。

sudo dpkg-reconfigure locales返回:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = "en_US:en",
    LC_ALL = "en_US.UTF-8",
    LC_PAPER = "en_US.UTF-8",
    LC_ADDRESS = "en_US.UTF-8",
    LC_MONETARY = "en_US.UTF-8",
    LC_NUMERIC = "en_US.UTF-8",
    LC_TELEPHONE = "en_US.UTF-8",
    LC_IDENTIFICATION = "en_US.UTF-8",
    LC_MEASUREMENT = "en_US.UTF-8",
    LC_TIME = "en_US.UTF-8",
    LC_NAME = "en_US.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)...

/usr/bin/locale返回:

LANG=en_US.UTF-8
LANGUAGE=en_US:en
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

然后我尝试:

sudo locale-gen "en_US.UTF-8"
sudo locale-gen --purge --no-archive
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8

重新登录

sudo apt-get upgrade仍然产生相同的结果。

根据 Ask Ubuntu 上的另一个答案,我尝试过

sudo apt install localesapt-get -f install由于同样的原因,这无法运行。

我的/etc/environment文件包含:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
LC_NUMERIC = "en_US.UTF-8"
LC_MONETARY = "en_US.UTF-8"
LC_PAPER = a4
LC_MEASUREMENT = "en_US.UTF-8"
LC_TIME = "en_US.UTF-8"
LC_ALL="en_US.UTF-8"
LANG="en_US.UTF-8"

/etc/default/locale文件包含:

#  File generated by update-locale
LANG=en_US.UTF-8
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_MONETARY="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"
LANGUAGE="en_US:en"
LC_ALL=en_US.UTF-8

我的 PATH 变量是:

/home/henkjan/bin:/home/henkjan/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

完整结果sudo apt-get upgrade

Reading package lists...
Building dependency tree...
Reading state information...
Calculating upgrade...
The following packages have been kept back:
  linux-generic linux-headers-generic linux-image-generic
The following packages will be upgraded:
  apparmor appmenu-qt5 desktop-file-utils eject firefox firefox-locale-en
  firefox-locale-nl flashplugin-installer gir1.2-appindicator3-0.1
  gir1.2-gst-plugins-base-1.0 gir1.2-gtk-3.0 gnome-software
  gnome-software-common grub-common grub-pc grub-pc-bin grub2-common
  gstreamer1.0-alsa gstreamer1.0-plugins-base gstreamer1.0-plugins-base-apps
  gstreamer1.0-plugins-good gstreamer1.0-pulseaudio gstreamer1.0-x imagemagick
  imagemagick-6.q16 libapparmor-perl libarchive13 libevent-2.0-5 libexiv2-14
  libgd3 libgstreamer-plugins-base1.0-0 libgstreamer-plugins-good1.0-0
  libgtk-3-bin libimage-magick-perl libimage-magick-q16-perl
  liblightdm-gobject-1-0 libmagick++-6.q16-5v5 libmagickcore-6.q16-2-extra
  libmetacity-private3a libnm-glib-vpn1 libnm-glib4 libnm-gtk-common
  libnm-gtk0 libnm-util2 libnm0 libnma-common libnma0 liboxideqt-qmlplugin
  liboxideqtcore0 liboxideqtquick0 libpci3 lightdm linux-libc-dev makedev
  metacity-common multiarch-support network-manager network-manager-gnome
  oxideqt-codecs-extra pciutils python-pil python3-pil resolvconf snap-confine
  snapd sni-qt thermald thunderbird thunderbird-gnome-support
  thunderbird-locale-en thunderbird-locale-en-gb thunderbird-locale-en-us
  thunderbird-locale-nl ubuntu-software wget
75 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
1 not fully installed or removed.
Need to get 0 B/146 MB of archives.
After this operation, 3316 kB of additional disk space will be used.
Do you want to continue? [Y/n] Preconfiguring packages ...
Setting up install-info (6.1.0.dfsg.1-5) ...
/usr/sbin/update-info-dir: 2: /etc/environment: LC_NUMERIC: not found
dpkg: error processing package install-info (--configure):
 subprocess installed post-installation script returned error exit status 127
Errors were encountered while processing:
 install-info

答案1

您应该删除/etc/environment除第一行(的设置PATH)之外的所有内容。除了LANGLC_*变量不属于那里(/etc/default/locale是它们的位置)之外,字符前后的空格=会使条目无效。

相关内容