How to fix a locale setting warning from Perl?

后端 未结 30 1385
清酒与你
清酒与你 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:10

    Following the accepted answer:

    LANG=C ssh hunter2.

    LC_ALL=C ssh hunter2

    on the client side did the trick for me.

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

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

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

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

    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.

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

    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"

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