Mar
08
2010
0

perl:locale warning

23:00 pm

Ubuntu Server9.10でアプリのインストール時に以下のWarningが頻発しており、うっとおしいので対策してみます。
Warningの内容は、以下のとおりperlからロケールの設定がおかしいというご指摘です。

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = “ja_JP.UTF-8″
are supported and installed on your system.
perl: warning: Falling back to the standard locale (“C”).

ロケールとは、ソフトウェアに内蔵される、言語や国・地域ごとに異なる単位、記号、日付、通貨などの表記規則の集合。または単に、利用する言語や国・地域の指定。多くのソフトウェアやプログラミング言語は、使用する言語とともにロケールを設定し、ロケールで定められた方式に基づいてデータの表記や処理を行なう。

簡単に言うと利用言語の設定ができていないということ。

自分のロケール設定は、以下で確認できます。
$ locale

Warning対策は、以下のようにすればいいらしい。

$ sudo apt-get install language-pack-ja
$ sudo dpkg-reconfigure locales

実行してみた結果です。

hbirds@ubuntu:~$ sudo apt-get install language-pack-ja
[sudo] password for hbirds:
Reading package lists... Done
Building dependency tree
Reading state information... Done
language-pack-ja is already the newest version.
The following packages were automatically installed and are no longer required:
  libmcrypt4 libjs-mootools php5-mcrypt dbconfig-common
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.
hbirds@ubuntu:~$ sudo dpkg-reconfigure locales
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LANG = "ja.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Generating locales...
  en_AG.UTF-8... done
  en_AU.UTF-8... done
  en_BW.UTF-8... done
  en_CA.UTF-8... done
  en_DK.UTF-8... done
  en_GB.UTF-8... done
  en_HK.UTF-8... done
  en_IE.UTF-8... done
  en_IN.UTF-8... done
  en_NG.UTF-8... done
  en_NZ.UTF-8... done
  en_PH.UTF-8... done
  en_SG.UTF-8... done
  en_US.UTF-8... done
  en_ZA.UTF-8... done
  en_ZW.UTF-8... done
  ja_JP.UTF-8... up-to-date
Generation complete.

$ loacle により、確認してみました。

hbirds@ubuntu:~$ locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=ja.UTF-8
LC_CTYPE="ja.UTF-8"
LC_NUMERIC="ja.UTF-8"
LC_TIME="ja.UTF-8"
LC_COLLATE="ja.UTF-8"
LC_MONETARY="ja.UTF-8"
LC_MESSAGES="ja.UTF-8"
LC_PAPER="ja.UTF-8"
LC_NAME="ja.UTF-8"
LC_ADDRESS="ja.UTF-8"
LC_TELEPHONE="ja.UTF-8"
LC_MEASUREMENT="ja.UTF-8"
LC_IDENTIFICATION="ja.UTF-8"
LC_ALL=  

上の3行でまだ、エラーが出ています。
$ sudo localedef -i ja_JP -f UTF-8 ja_JP.UTF-8 とやってみたが、ダメです。

$ sudo dpkg-reconfigure locales としてみました。
このフォーラムによるとこのコマンドで消すことができているようです。

hbirds@UbuntuServer:~$ sudo dpkg-reconfigure locales
[sudo] password for hbirds:
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LANG = "ja.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Generating locales...
  en_AG.UTF-8... up-to-date
  en_AU.UTF-8... up-to-date
  en_BW.UTF-8... up-to-date
  en_CA.UTF-8... up-to-date
  en_DK.UTF-8... up-to-date
  en_GB.UTF-8... up-to-date
  en_HK.UTF-8... up-to-date
  en_IE.UTF-8... up-to-date
  en_IN.UTF-8... up-to-date
  en_NG.UTF-8... up-to-date
  en_NZ.UTF-8... up-to-date
  en_PH.UTF-8... up-to-date
  en_SG.UTF-8... up-to-date
  en_US.UTF-8... up-to-date
  en_ZA.UTF-8... up-to-date
  en_ZW.UTF-8... up-to-date
  ja_JP.UTF-8... up-to-date
Generation complete.

$ sudo localedef -f UTF-8 -i ja_JP ja_JP としてみたがダメ

ダメです。もう少しお勉強が必要なようです。
どなたかご教示いただけると嬉しいです。

その後、以下のサイトを発見!
たぶん、ここに書かれているように環境変数 PERL_BANDLANGを設定することで制御できるようです。
perl講座:Perlのインストール(UNIX版)
Ubuntu は、sh系なので、以下のコマンドを実施することになります。

$ PERL_BADLANG=0
$ export PERL_BADLANG

↑を実行したけど無反応!

How to solve the error of “locale: cannot set LC_CTYPE to default locale: No such file or directory” and similar?

If you got this error, that means the environmental variable (in this case, it is LC_CTYPE) does not contain a reconganizable locale your system knows. This may be caused by two possibilities:

1. The locale you set to LC_CTYPE is misspelled;
2. The locale you specified is not installed in your system, inorder to find out whether this is the case, do a

locale -a

and see whether the locale you specified is contained in the output of that command. If it can not be found in the output, then you have to install that locale. Please refer to the doc about how to configure SCIM.

このサイトも参考になるかな

www.hbirds.net