46
45

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【CentOS6】「LC_CTYPE: cannot change locale (UTF-8): そのようなファイルやディレクトリはありません」が出たときの対処法

Last updated at Posted at 2014-12-28

##現象

・centOS全体で、日本語が文字化けする
 (git logでコミットログの日本語読めないのが辛い)
・ログイン毎にwarningが出る

Welcome to your Vagrant-built virtual machine.
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): そのようなファイルやディレクトリはありません

localeコマンドを叩いても警告

[vagrant@localhost ~]$ locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: LC_ALL?????????????????????: ??????????????????????
LANG=ja_JP.utf8
LC_CTYPE=UTF-8
LC_NUMERIC="ja_JP.utf8"
LC_TIME="ja_JP.utf8"
LC_COLLATE="ja_JP.utf8"
LC_MONETARY="ja_JP.utf8"
LC_MESSAGES="ja_JP.utf8"
LC_PAPER="ja_JP.utf8"
LC_NAME="ja_JP.utf8"
LC_ADDRESS="ja_JP.utf8"
LC_TELEPHONE="ja_JP.utf8"
LC_MEASUREMENT="ja_JP.utf8"
LC_IDENTIFICATION="ja_JP.utf8"
LC_ALL=

##原因
そもそも日本語化しようとして、
/etc/sysconfig/i18n
このファイルに、
LANG="ja_JP.utf8"
を書き加えたのち、警告が出るようになった

LC_CTYPEの設定が足りていない?

##対処法

一時回避はこれでできた
export LC_CTYPE='ja_JP.UTF-8'
しかし再起動すると戻ってしまう。

これを永続的に設定するには、再び下記ファイルを編集する

sudo vim /etc/sysconfig/i18n

LANG="ja_JP.UTF-8"
LC_CTYPE="ja_JP.UTF-8" ←これを追加
SYSFONT="latarcyrheb-sun16"

再起動すれば、もうwarningは出ないはず!

localeを叩いても警告はでません。

[vagrant@localhost ~]$ locale
LANG=ja_JP.UTF-8
LC_CTYPE=ja_JP.UTF-8
LC_NUMERIC="ja_JP.UTF-8"
LC_TIME="ja_JP.UTF-8"
LC_COLLATE="ja_JP.UTF-8"
LC_MONETARY="ja_JP.UTF-8"
LC_MESSAGES="ja_JP.UTF-8"
LC_PAPER="ja_JP.UTF-8"
LC_NAME="ja_JP.UTF-8"
LC_ADDRESS="ja_JP.UTF-8"
LC_TELEPHONE="ja_JP.UTF-8"
LC_MEASUREMENT="ja_JP.UTF-8"
LC_IDENTIFICATION="ja_JP.UTF-8"
LC_ALL=
46
45
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
46
45

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?