CentOS 8 – Failed to set locale.

Loading

測試環境為 CentOS 8 x86_64

執行指令時蠻常出現這個錯誤訊息的.

Failed to set locale.

這是跟語系相關的錯誤訊息.需正確設定 Locale 語系環境及其所需套件.

可以使用指令 locale , localectl 檢視目前系統 Locale 與 鍵盤的設置為何.

[root@localhost ~]# locale
LANG=en_US.UTF-8
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=
[root@localhost ~]# localectl
   System Locale: LANG=en_US.UTF-8
       VC Keymap: us
      X11 Layout: us

一樣可以透過指令 localectl 設定系統 Locale 與 鍵盤,這邊設定成 en_US.UTF-8 語言,

[root@localhost ~]# localectl set-locale LANG=en_US.UTF-8
[root@localhost ~]# localectl
   System Locale: LANG=en_US.UTF-8
       VC Keymap: us
      X11 Layout: us

或是設定檔

[root@localhost ~]# vi /etc/environment
LANG=zh_TW.utf-8
LC_ALL=zh_TW.utf-8

檢視是否有安裝相關語言套件.

[root@localhost ~]# rpm -aq | grep -i langpacks-en
langpacks-en-1.0-12.el8.noarch
[root@localhost ~]# rpm -aq | grep -i glibc-all-langpacks
glibc-all-langpacks-2.28-155.el8.x86_64

無,則安裝.

[root@localhost ~]# dnf install langpacks-en glibc-all-langpacks -y
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:31:18 ago on Tue Apr 27 11:19:34 2021.
Package langpacks-en-1.0-12.el8.noarch is already installed.
Dependencies resolved.
=================================================================================================================
 Package                           Architecture         Version                       Repository            Size
=================================================================================================================
Installing:
 glibc-all-langpacks               x86_64               2.28-155.el8                  baseos                25 M
Upgrading:
 glibc                             x86_64               2.28-155.el8                  baseos               3.6 M
 glibc-common                      x86_64               2.28-155.el8                  baseos               1.3 M
 glibc-langpack-en                 x86_64               2.28-155.el8                  baseos               827 k

Transaction Summary
=================================================================================================================
Install  1 Package
Upgrade  3 Packages

這樣就不會再看到這個錯誤訊息了.

沒有解決問題,試試搜尋本站其他內容

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料