How to fix a locale setting warning from Perl?

后端 未结 30 1389
清酒与你
清酒与你 2020-11-27 08:36

When I run perl, I get the warning:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset         


        
相关标签:
30条回答
  • 2020-11-27 09:27

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

    0 讨论(0)
  • 2020-11-27 09:28

    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
    
    0 讨论(0)
  • 2020-11-27 09:30

    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_CTYPE=en_US.UTF-8
    
    0 讨论(0)
  • 2020-11-27 09:33

    Use:

    export LANGUAGE=en_US.UTF-8
    export LC_ALL=en_US.UTF-8
    export LANG=en_US.UTF-8
    export LC_CTYPE=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.

    0 讨论(0)
  • 2020-11-27 09: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.

    0 讨论(0)
  • 2020-11-27 09:34

    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:

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

    0 讨论(0)
提交回复
热议问题