35
15

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.

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

Last updated at Posted at 2016-07-14

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に変えれば大丈夫だと思います。

35
15
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
35
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?