How to fix a locale setting warning from Perl?

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

    Export the variable

    $ 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
    

    Next run

    $ sudo locale-gen
    $ sudo dpkg-reconfigure locales 
    

    When you run dpkg-reconfigure locales it asks you to choose the locales, choose en_US.UTF-8 . If you run this by selecting all locales, it will take some time to configure.

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

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

    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)

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

    This is a quick answer. We will set locales that are not unset after reboot. First open bash file and edit it :

    nano .bashrc
    

    add these lines to the file :

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

    activate change by reloading bash :

    source ~/.bashrc
    

    test results :

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

    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.

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

    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,

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