csdnceshi75
衫裤跑路
采纳率0%
2010-03-23 12:27 阅读 543

如何修复来自 Perl 的语言环境设置警告?

When I run perl, I get the warning:

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

How do I fix it?

转载于:https://stackoverflow.com/questions/2499794/how-to-fix-a-locale-setting-warning-from-perl

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

30条回答 默认 最新

  • 已采纳
    csdnceshi50 三生石@ 2010-03-24 18:50

    Your OS doesn't know about en_US.UTF-8.

    You didn't mention a specific platform, but I can reproduce your problem:

    % uname -a
    OSF1 hunter2 V5.1 2650 alpha
    % perl -e exit
    perl: warning: Setting locale failed.
    perl: warning: Please check that your locale settings:
        LC_ALL = (unset),
        LANG = "en_US.UTF-8"
        are supported and installed on your system.
    perl: warning: Falling back to the standard locale ("C").

    My guess is you used ssh to connect to this older host from a newer desktop machine. It's common for /etc/ssh/sshd_config to contain

    AcceptEnv LANG LC_*
    

    which allows clients to propagate into new sessions the values of those environment variables.

    The warning gives you a hint about how to squelch it if you don't require the full-up locale:

    % env LANG=C perl -e exit
    %

    or with bash:

    $ LANG=C perl -e exit
    $ 

    For a permanent fix, choose one of

    1. On the older host, set the LANG environment variable in your shell's initialization file.
    2. Modify your environment on the client side, e.g., rather than ssh hunter2, use the command LANG=C ssh hunter2.
    3. If you have admin rights, stop ssh from sending the environment variables by commenting out the SendEnv LANG LC_* line in the local /etc/ssh/ssh_config file. (Thanks to this answer. See Bug 1285 for OpenSSH for more.)
    点赞 24 评论 复制链接分享
  • csdnceshi78 程序go 2010-03-23 12:33

    This generally means you haven't properly set up locales on your Linux box.

    On Debian or Ubuntu, that means you need to do

    $ sudo locale-gen
    $ sudo dpkg-reconfigure locales

    See also man locale-gen.

    点赞 24 评论 复制链接分享
  • weixin_41568196 撒拉嘿哟木头 2012-03-15 20:28

    If you are creating a rootfs using debootstrap you will need to generate the locales. You can do this by running:

    # (optional) enable missing locales
    sudo nano /etc/locale.gen
    
    # then regenerate
    sudo locale-gen
    

    This tip comes from, https://help.ubuntu.com/community/Xen

    点赞 24 评论 复制链接分享
  • csdnceshi68 local-host 2011-09-14 09:09

    Here is how to solve it on Mac OS Lion (10.7) or Cygwin (Windows 10):

    Add the following lines to your bashrc or bash_profile on the host machine:

    # Setting for the new UTF-8 terminal support in Lion
    export LC_CTYPE=en_US.UTF-8
    export LC_ALL=en_US.UTF-8
    

    If you are using zsh, edit zshrc:

    # Setting for the new UTF-8 terminal support in Lion
    LC_CTYPE=en_US.UTF-8
    LC_ALL=en_US.UTF-8
    
    点赞 22 评论 复制链接分享
  • csdnceshi68 local-host 2014-03-17 13:25

    Use:

    export LANGUAGE=en_US.UTF-8
    export LC_ALL=en_US.UTF-8
    export LANG=en_US.UTF-8
    export LC_TYPE=en_US.UTF-8
    

    It works for Debian. I don't know why - but locale-gen had not results.

    Important! It's a temporary solution. It has to be run for each session.

    点赞 22 评论 复制链接分享
  • csdnceshi72 谁还没个明天 2014-02-16 17:56

    Following the accepted answer:

    LANG=C ssh hunter2.

    LC_ALL=C ssh hunter2

    on the client side did the trick for me.

    点赞 10 评论 复制链接分享
  • csdnceshi55 ~Onlooker 2014-04-09 21:24

    You need to configure locale appropriately in /etc/default/locale, logout, login, and then run the regular commands

    root@host:~# echo -e 'LANG=en_US.UTF-8\nLC_ALL=en_US.UTF-8' > /etc/default/locale
    root@host:~# exit
    local-user@local:~$ ssh root@host
    root@host:~# locale-gen en_US.UTF-8
    root@host:~# dpkg-reconfigure locales
    
    点赞 10 评论 复制链接分享
  • csdnceshi54 hurriedly% 2014-11-08 19:03

    In my case, this was the output:

    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_PAPER = "ro_RO.UTF-8",
    LC_ADDRESS = "ro_RO.UTF-8",
    ....
    

    The solution was:

    sudo locale-gen ro_RO.UTF-8
    
    点赞 10 评论 复制链接分享
  • weixin_41568110 七度&光 2017-08-06 08:44

    in my case, with debian8.6, i had to change settings in:

    /etc/ssh/ssh_config for #AcceptEnv LANG LC_*

    and sshd_config for #SendEnv LANG LC_*

    then restart ssh service.

    at last, did

    locale-gen en_US.UTF-8 and dpkg-reconfigure locales

    点赞 10 评论 复制链接分享
  • csdnceshi68 local-host 2014-12-31 17:40

    It is simple fix in Ubuntu. You have to generate the Locales from scratch, running the following commands from the command line:

    sudo locale-gen en_US en_US.UTF-8
    sudo dpkg-reconfigure locales
    

    This should create the locales and then re-configure them.

    点赞 9 评论 复制链接分享
  • weixin_41568126 乱世@小熊 2017-11-08 09:44

    Add missing locales to .bash_profile

    echo "export LANGUAGE=en_US.UTF-8
    export LANG=en_US.UTF-8
    export LC_ALL=en_US.UTF-8">>~/.bash_profile
    

    Then source your .bash_profile

    source ~/.bash_profile
    
    点赞 8 评论 复制链接分享
  • weixin_41568174 from.. 2018-03-03 21:14

    Adding the correct locale to ~/.bashrc, ~/.bash_profile, /etc/environment and the like will solve the problem, however it is not recommended, as it overrides the settings from /etc/default/locale, which is confusing at best and may lead to the locales not being applied consistently at worst.

    Instead, one should edit /etc/default/locale directly, which may look something like this:

    LANG=en_US.UTF-8
    LANGUAGE=en_US:en
    LC_CTYPE=en_US
    
    点赞 8 评论 复制链接分享
  • csdnceshi63 elliott.david 2016-02-24 19:22
    perl: warning: Falling back to the standard locale ("C").
    locale: Cannot set LC_ALL to default locale: No such file or directory
    

    Solution:

    Try this (uk_UA.UTF-8 is my current locale. Write your locale, for example en_US.UTF-8 !)

    sudo locale-gen uk_UA.UTF-8
    

    and this.

    sudo dpkg-reconfigure locales
    
    点赞 7 评论 复制链接分享
  • weixin_41568126 乱世@小熊 2016-10-21 20:18

    For me, on Ubuntu 16.04 (Xenial Xerus) the following worked:

    root@host:~#locale-gen en_GB.UTF-8
    root@host:~#localectl set-locale LANG=en_GB.UTF-8,LC_ALL=en_GB.UTF-8
    

    Then reboot...

    点赞 7 评论 复制链接分享
  • weixin_41568134 MAO-EYE 2018-01-03 17:07

    for me I fix this error editing the .bashrc file add export. Add after initial comments.

    Add language suport.

    export LANGUAGE=en_US.UTF-8
    export LC_ALL=en_US.UTF-8
    export LANG=en_US.UTF-8
    export LC_TYPE=en_US.UTF-8
    

    Kind Regads,

    点赞 7 评论 复制链接分享
  • weixin_41568183 零零乙 2013-12-17 06:33

    For macOS & Mac OS X users only

    I was getting the same warning while using Git

    To resolve this warning Uncheck the Set locale environment variable on startup option and restart your terminal. Below screen shot represents my terminal settings.

    enter image description here

    点赞 5 评论 复制链接分享
  • weixin_41568131 10.24 2015-02-25 16:06

    I am now using this:

    $ cat /etc/environment
    ...
    LC_ALL=en_US.UTF-8
    LANG=en_US.UTF-8
    

    Then log out of SSH session and log in again.

    Old answer:

    Only this helped me:

    $ locale
    locale: Cannot set LC_ALL to default locale: No such file or directory
    LANG=en_US.UTF-8
    LANGUAGE=
    LC_CTYPE=en_US.UTF-8
    LC_NUMERIC=ru_RU.UTF-8
    LC_TIME=ru_RU.UTF-8
    LC_COLLATE="en_US.UTF-8"
    LC_MONETARY=ru_RU.UTF-8
    LC_MESSAGES="en_US.UTF-8"
    LC_PAPER=ru_RU.UTF-8
    LC_NAME=ru_RU.UTF-8
    LC_ADDRESS=ru_RU.UTF-8
    LC_TELEPHONE=ru_RU.UTF-8
    LC_MEASUREMENT=ru_RU.UTF-8
    LC_IDENTIFICATION=ru_RU.UTF-8
    LC_ALL=
    
    $ sudo su
    
    # export LANGUAGE=en_US.UTF-8
    # export LANG=en_US.UTF-8
    # export LC_ALL=en_US.UTF-8
    
    # locale-gen en_US.UTF-8
    Generating locales...
      en_US.UTF-8... up-to-date
    Generation complete.
    
    # 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... up-to-date
      en_ZA.UTF-8... done
      en_ZM.UTF-8... done
      en_ZW.UTF-8... done
    Generation complete.
    
    # exit
    
    $ locale
    LANG=en_US.UTF-8
    LANGUAGE=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
    
    点赞 5 评论 复制链接分享
  • weixin_41568196 撒拉嘿哟木头 2017-10-25 17:52

    For anyone connecting to DigitalOcean or some other Cloud hosting provider from the iTerm2.app on MacOS High Sierra and getting this error on some commands:

    perl: warning: Setting locale failed.
    perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LC_CTYPE = "UTF-8",
        LANG = "en_US.UTF-8"
      are supported and installed on your system.
    perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
    

    This fixed the problem for me:

    enter image description here

    I know this thread is old but maybe somebody will find this useful. I know how annoying this can be.

    点赞 5 评论 复制链接分享
  • csdnceshi60 ℡Wang Yan 2014-06-16 13:46
    sudo nano /etc/locale.gen
    

    Uncomment the locales you want to use (e.g. en_US.UTF-8 UTF-8):

    Then run:

    sudo /usr/sbin/locale-gen
    

    Source: http://people.debian.org/~schultmc/locales.html

    点赞 4 评论 复制链接分享
  • csdnceshi78 程序go 2014-08-29 12:01

    As always, the devil is in the detail...

    On Mac OS X v10.7.5 (Lion), to fix some Django error, in my ~/.bash_profile I've set:

    export LANG=en_EN.UTF-8
    export LC_COLLATE=$LANG
    export LC_CTYPE=$LANG
    export LC_MESSAGES=$LANG
    export LC_MONETARY=$LANG
    export LC_NUMERIC=$LANG
    export LC_TIME=$LANG
    export LC_ALL=$LANG
    

    And in turn for a long time I got that warning when using Perl.

    My bad! As I've realized much later, my system is en_US.UTF-8! I fixed it simply by changing from

    export LANG=en_EN.UTF-8
    

    to

    export LANG=en_US.UTF-8
    
    点赞 4 评论 复制链接分享
  • csdnceshi51 旧行李 2014-09-18 05:34

    on Debian after much searching this did the trick.

    first:

    sudo apt-get purge locales
    

    then:

    sudo aptitude install locales
    

    and the famous:

    sudo dpkg-reconfigure locales
    

    This rids the system of locales, then re-installs locales and downgrades libc6 from 2.19 to 2.13 which is the issue. Then configures locales again.

    点赞 4 评论 复制链接分享
  • csdnceshi59 ℙℕℤℝ 2017-11-28 20:27

    In Arch Linux using a UK keyboard / locale I had the following error:

    perl: warning: Setting locale failed.
    perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LANG = "en_US.utf8"
    
    • Exporting my locales in /etc/profile didn't fix it.

    • I did however fix this by editing /etc/locale.gen & also enabling
      the en_US.utf8 locale that perl expected to find & running local-gen.

    (I use pac-manager which uses a whole bunch of perl modules from AUR so reinstalling perl in my particular case would be a nuisance)

    点赞 3 评论 复制链接分享
  • csdnceshi56 lrony* 2018-04-12 12:59

    For Ubuntu use this,

    #export LANGUAGE=en_US.UTF-8
    #export LC_ALL=en_US.UTF-8
    #export LANG=en_US.UTF-8
    #export LC_TYPE=en_US.UTF-8
    

    Worked for me.

    点赞 3 评论 复制链接分享
  • csdnceshi71 Memor.の 2014-01-26 12:09

    Adding the following to /etc/environment fixed the problem for me on Debian and Ubuntu (of course, modify to match the locale you want to use):

    LANGUAGE=en_US.UTF-8
    LC_ALL=en_US.UTF-8
    LANG=en_US.UTF-8
    LC_TYPE=en_US.UTF-8
    
    点赞 2 评论 复制链接分享
  • weixin_41568184 叼花硬汉 2015-07-13 08:24

    Add LC_ALL="en_GB.utf8" to /etc/environment and reboot. That's all.

    点赞 2 评论 复制链接分享
  • csdnceshi50 三生石@ 2015-08-27 14:02

    ssh overwrites LC locale variables by default. See /etc/ssh/sshd_config:

    AcceptEnv LANG LC_*
    

    So maybe you need to set these variables in your local shell.

    点赞 2 评论 复制链接分享
  • csdnceshi73 喵-见缝插针 2015-12-15 23:33

    If you use Mac OS X v10.10 (Yosemite) or above to connect in your server Linux, you can try these steps.

    1. Keep your file /etc/ssh/sshd-config original

    2. Put on your ~/.bash_profile

      export LANG="en_US"
      export LC_ALL=$LANG.UTF-8
      
    3. Run

      dpkg-reconfigure locales
      

      And select "en_US.UTF-8"

    点赞 2 评论 复制链接分享
  • weixin_41568174 from.. 2016-10-04 14:36

    If you don't care about the locale issue, you can set PERL_BADLANG=0. Of course, this could result in incorrect localisation.

    点赞 1 评论 复制链接分享
  • csdnceshi54 hurriedly% 2016-12-25 11:02

    With zsh ohmyzsh I added this to the .zshrc:

     # You may need to manually set your language environment
     LANGUAGE=en_US.UTF-8
     LANG=en_US.UTF-8
     LC_CTYPE=en_US.UTF-8
     LC_ALL=en_US.UTF-8
    

    By removing the line export LANG=en_US.UTF-8

    Reopened a new tab and SSHed in, worked for me :)

    点赞 1 评论 复制链接分享
  • csdnceshi55 ~Onlooker 2017-05-10 21:27

    All the previous answers are wrong. The message is clear - missing locale. The solution is to add the appropriate locale. You do that by editing the /etc/locale.gen file, remove the # sign in front of the locale being reported as missing and then issuing the command:

    $ sudo locale-gen
    

    This will actually generate the locales specified in /etc/locale.gen and therefore the message will not be shown.

    点赞 1 评论 复制链接分享

相关推荐