从ubuntu 16.04更新到18.04后,我收到以下警告:加载/ etc / profile时发现错误,无法将LC_CTYPE设置为默认语言环境。警告消息还列出LC_MESSAGES和LC_ALL具有相同的问题。
这是我的/ etc / profile
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ "${PS1-}" ]; then
if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then
# The file bash.bashrc already sets the default PS1.
# PS1='\h:\w\$ '
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
else
if [ "`id -u`" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
当我尝试运行sudo dpkg-reconfigure locales时,它返回...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = "en_US.UTI-8",
LC_CTYPE = "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
locales-all installed, skipping locales generation
*** update-locale: Error: invalid locale settings: LANG=en_US.UTF-8 LC_ALL="en_US.UTI-8" LC_CTYPE="en_US.UTF-8"
我尝试了以下方法:
sudo locale-gen
[sudo] password for go:
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Generating locales (this might take a while)...
en_AG.UTF-8... done
en_AU.UTF-8... done
en_BW.UTF-8... done
en_CA.UTF-8... done
en_DK.UTF-8... done
en_GB.UTF-8... done
en_HK.UTF-8... done
en_IE.UTF-8... done
en_IL.UTF-8... done
en_IN.UTF-8... done
en_NG.UTF-8... done
en_NZ.UTF-8... done
en_PH.UTF-8... done
en_SG.UTF-8... done
en_US.UTF-8... done
en_ZA.UTF-8... done
en_ZM.UTF-8... done
en_ZW.UTF-8... done
Generation complete.
go@go-Aspire-TC-705:~$ sudo dpkg-reconfigure locales
locales-all installed, skipping locales generation
*** update-locale: Error: invalid locale settings: LANG=en_US.UTF-8 LC_CTYPE="en_US.UTF-8" LC_ALL="en_US.UTI-8"
我现在可以运行需要区域设置的程序,但更新区域设置会抱怨无效的区域设置。
我在这里过头了。请帮忙。
在查看我的问题中列出的最后一条错误消息后,我注意到LC_ALL被设置为LC_ALL =“en_US.UTI-8”。我编辑了/ etc / default / locale并将UTI更改为UTF,现在一切似乎都在工作。我不是100%确定locale-gen命令将LC_ALL分配给UTI ......我不相信我这样做了。
无论如何我的解决方案是sudo locale-gen,编辑/ etc / default / locale
LC_CTYPE="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
#LANG="en_US.UTF-8"
问题解决了。