Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
46
Help us understand the problem. What is going on with this article?
@Tamiiy

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

More than 5 years have passed since last update.

現象

・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
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Tamiiy
セブから生まれた渋谷のアプリ&Web屋。ハイブリッドアプリ信者だけどSwiftも気になる https://freelance-start.com

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
46
Help us understand the problem. What is going on with this article?