目の前に僕らの道がある

勉強会とか、技術的にはまったことのメモ

Ubuntuのlocaleが正しく設定されていない時の対処メモ

VPSに入っているUbuntu 10.04に日本語localeが設定されていなかったので、少しはまったのでメモ。
たぶん、あと同じことで2,3回くらいはまりそうなので、残しておきます。

現象

.zshrcにLANGを設定したらperlのlocaleエラーが出るようになった。

export LANG="ja_JP.UTF-8"
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の追加とlocaleの再設定をした

[ VPS-LAB ] masasuzu@lab% sudo locale-gen ja_JP.UTF-8
Generating locales...
  ja_JP.UTF-8... done
Generation complete.
[ VPS-LAB ] masasuzu@lab% sudo dpkg-reconfigure locales
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_ZM.UTF-8... cannot open locale definition file `en_ZM': No such file or directory
failed
  en_ZW.UTF-8... done
  ja_JP.UTF-8... up-to-date
Generation complete.
sudo dpkg-reconfigure locales  17.37s user 1.44s system 110% cpu 17.086 total

perl -v を実行してエラーが出なければOK。

[ VPS-LAB ] masasuzu@lab% perl -v

This is perl, v5.10.1 (*) built for x86_64-linux-gnu-thread-multi

Copyright 1987-2009, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.