CentOS 8 – Failed to set locale.

測試環境為 CentOS 8 x86_64

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

Failed to set locale.

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

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

[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 ~]# 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 如何處理網站訪客的留言資料