15
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

updated at

CentOS7 LC_CTYPE: cannot change locale (UTF-8): No such file or directory

CentOS 7

*i18nのファイルを作るみたいなことが書いてあるサイトがたくさんあって試してみたが、できなかった、自分のはそれは関係なかった。
ので
http://stackoverflow.com/questions/22430747/locale-error-in-centos
ここを参考にしたら直りました。
以下日本語訳です。

CentOSを立ち上げると、いつも

-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory

というのがでたり、
localeコマンドをすると、

$ locale

locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LC_CTYPE=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=

この二つがいつもでるので直したかった。

locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory

直す

viコマンドでenvironmentファイルを新規に作成する。

sudo vi /etc/environment

その中にこの2行を書くだけ。

aを押して挿入モードに。

LANG=en_US.utf-8
LC_ALL=en_US.utf-8

escキー(コマンドモードに)  →:wq     で保存

[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=en_US.utf-8
[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=en_US.utf-8

これでもうログインしたり、localeを見た時にエラーは出なくなる。

日本語の場合はen_USのところをja_JPに変えれば大丈夫だと思います。

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
Sign upLogin
15
Help us understand the problem. What are the problem?