環境
- OS: CentOS Linux release 8.2.2004 (オンプレ/実機)
- Kernel: 4.18.0-193.6.3.el8_2.x86_64
- Locale: System Locale: LANG=en_US.UTF-8
現象
[root@nbs2 ~]# dnf check
Failed to set locale, defaulting to C.UTF-8
[root@nbs2 ~]#
原因
- 言語パッケージがインストールされていない
[root@nbs2 ~]# localectl status
System Locale: LANG=en_US.UTF-8
VC Keymap: jp
X11 Layout: jp
[root@nbs2 ~]#
[root@nbs2 ~]# localectl list-locales
C.utf8
ja_JP.eucjp
ja_JP.utf8
[root@nbs2 ~]#
[root@nbs2 ~]# dnf info langpacks-ja
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:50:25 ago on Sun Jun 21 14:39:30 2020.
Installed Packages
Name : langpacks-ja
Version : 1.0
Release : 12.el8
Architecture : noarch
Size : 402
Source : langpacks-1.0-12.el8.src.rpm
Repository : @System
From repo : AppStream
Summary : Japanese langpacks meta-package
License : GPLv2+
Description : This package provides Japanese langpacks meta-package.
[root@nbs2 ~]#
[root@nbs2 ~]# dnf info langpacks-en
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:50:32 ago on Sun Jun 21 14:39:30 2020.
Available Packages
Name : langpacks-en
Version : 1.0
Release : 12.el8
Architecture : noarch
Size : 9.6 k
Source : langpacks-1.0-12.el8.src.rpm
Repository : AppStream
Summary : English langpacks meta-package
License : GPLv2+
Description : This package provides English langpacks meta-package.
[root@nbs2 ~]#
処置
参考
RHEL8でコマンド実行時に Failed to set locale, defaulting to C と表示される - Qiita
RHEL 8 の導入における検討事項 Red Hat Enterprise Linux 8 | Red Hat Customer Portal
内容
dnf -y install langpacks-en
dnf -y install langpacks-en
実行すれば解決
場合によっちゃ依存関係で他のパッケージも必要になるけど dnf(yumはCentos8では非推奨) 使えば一瞬
[root@nbs2 ~]# dnf list langpacks-en
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:56:16 ago on Sun Jun 21 14:39:30 2020.
Available Packages
langpacks-en.noarch 1.0-12.el8 AppStream
[root@nbs2 ~]#
Available Packages になっているのでインストールされていない。
[root@nbs2 ~]# dnf -y install langpacks-en
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:56:27 ago on Sun Jun 21 14:39:30 2020.
Dependencies resolved.
====================================================================================================
Package Architecture Version Repository Size
====================================================================================================
Installing:
langpacks-en noarch 1.0-12.el8 AppStream 9.6 k
Installing weak dependencies:
glibc-langpack-en x86_64 2.28-101.el8 BaseOS 821 k
Transaction Summary
====================================================================================================
Install 2 Packages
Total download size: 831 k
Installed size: 6.0 M
Downloading Packages:
(1/2): langpacks-en-1.0-12.el8.noarch.rpm 103 kB/s | 9.6 kB 00:00
(2/2): glibc-langpack-en-2.28-101.el8.x86_64.rpm 1.2 MB/s | 821 kB 00:00
----------------------------------------------------------------------------------------------------
Total 400 kB/s | 831 kB 00:02
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : glibc-langpack-en-2.28-101.el8.x86_64 1/2
Installing : langpacks-en-1.0-12.el8.noarch 2/2
Running scriptlet: langpacks-en-1.0-12.el8.noarch 2/2
Verifying : langpacks-en-1.0-12.el8.noarch 1/2
Verifying : glibc-langpack-en-2.28-101.el8.x86_64 2/2
Installed products updated.
Installed:
glibc-langpack-en-2.28-101.el8.x86_64 langpacks-en-1.0-12.el8.noarch
Complete!
[root@nbs2 ~]#
Installed と Complete! が表示されればOK
不安だったらrpm -q langpacks-en
叩けばいい
インストールされてなければpackage langpacks-en is not installed
と表示される
langpacks-en
[root@nbs2 ~]# rpm -q langpacks-en
langpacks-en-1.0-12.el8.noarch
[root@nbs2 ~]#
langpacks-eu
[root@nbs2 ~]# rpm -q langpacks-eu
package langpacks-eu is not installed
[root@nbs2 ~]#
[root@nbs2 ~]# localectl status
System Locale: LANG=en_US.UTF-8
VC Keymap: jp
X11 Layout: jp
[root@nbs2 ~]# localectl list-locales
C.utf8
en_AG
en_AU
en_AU.utf8
en_BW
en_BW.utf8
en_CA
en_CA.utf8
en_DK
en_DK.utf8
en_GB
en_GB.iso885915
en_GB.utf8
en_HK
en_HK.utf8
en_IE
en_IE.utf8
en_IE@euro
en_IL
en_IN
en_NG
en_NZ
en_NZ.utf8
en_PH
en_PH.utf8
en_SC.utf8
en_SG
en_SG.utf8
en_US
en_US.iso885915
en_US.utf8
en_ZA
en_ZA.utf8
en_ZM
en_ZW
en_ZW.utf8
ja_JP.eucjp
ja_JP.utf8
[root@nbs2 ~]#
en_* が増えた
[root@nbs2 ~]# dnf check
[root@nbs2 ~]#
インストールしたら Failed to set locale, defaulting to C.UTF-8 が出なくなった