My question is not about how to fix it, but about what causing perl warning in debian after doing apt-get install. I found the easiest way to fix this issue is:

export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
dpkg-reconfigure locales

After doing that, apt-get install --reinstall not throwing warning about locale unset anymore.

What I want to know is what is causing this issue? I happens after fresh install. I'm doing installation alot in virtual box for testing purpose. And every install have this issue. And, the issue is back after reboot? It happens on ubuntu too.

So, can anyone tell me what is causing locale issue?

  • I see this problem reported fairly often. I think you should clarify that you aren't looking for a solution to the perl locale warning (dpkg-reconfigure locales evidently works) but for an explanation of why it has to be done in the first place. – goldilocks Jul 12 '15 at 12:26
  • Yes it works. And the issue will come back randomly. I googled, and I can only find solutions without any explanation what is causing this and how this issue can affect the system. – Mas Bagol Jul 12 '15 at 12:30
  • @BagolDaplun are you running testing or unstable? I believe this is often a result of perl transitions in the non-stable branches. – jordanm Jul 12 '15 at 14:58
  • It's stable release – Mas Bagol Jul 12 '15 at 15:55

It's known that Perl complains loudly on starting up when it fails to find the compiled locale data in /usr/lib/locale/.../ or /usr/lib/locale/locale-archive for the locale you specify in the environment variables (LANG and others). It's easily reproducible like this:

$ LANG=xyz perl /dev/null
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_PAPER = "ja_JP.UTF-8",
    LC_ADDRESS = "ja_JP.UTF-8",
    LC_MONETARY = "ja_JP.UTF-8",
    LC_NUMERIC = "ja_JP.UTF-8",
    LC_TELEPHONE = "ja_JP.UTF-8",
    LC_TIME = "ja_JP.UTF-8",
    LC_NAME = "ja_JP.UTF-8",
    LANG = "xyz"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

So basically you should check available locales in the system and your locale settings in the environment variables when you see warnings above.

You can use locale -a to see all available locales, or localedef to list/add/delete compiled locales in locale-archive.

$ localedef --list-archive

locale-gen is a Debian specific wrapper script for localedef with config file /etc/locale.gen. dpkg-reconfigure locales updates /etc/locale.gen then just calls locale-gen.

Note that Ubuntu has the same command locale-gen, but its implementation seems quite different than Debian. It sees /var/lib/locales/supported.d/ for config and dpkg-reconfigure locales has no effect on Ubuntu. See also the community wiki instruction.

Locale related variables are set in your environment by various programs explicitly or implicitly. They would usually be initialized by pam_env.so with /etc/default/locale or ~/.pam_environment in the beginning of the session. More notably ssh will automatically send local locale settings to remote host sessions per default in Debian/Ubuntu. You can see the following line in /etc/ssh/ssh_config, which is mentioned in ssh_config manual page.

    SendEnv LANG LC_*
  • I understand it know after read your last paragraph, Locale related ... . May be it's because I login via ssh to debian VM. One more question, is it alter the default configuration in the machine that I login to? – Mas Bagol Jul 14 '15 at 14:06
  • In the SSH session, environment variables seem to get updated in the following order: 1) SendEnv by SSH, 2) libpam_env.so by PAM, 3) shell's start up scripts (.profile .bashrc etc.). You have enough knowledge to find the cause of the problem for yourself when you encounter it in the next time. Good luck! – yaegashi Jul 14 '15 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.