perl: warning: Setting locale failed - Solved - How To?

I have started receiving Perl locale warnings despite LC_CTYPE was set to "en_IN". Don't know what triggered it on my machine!
Every Perl script call was emitting these locale warnings.

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 the standard locale ("C").

Well I know there are different ways to solve this problem based on different distribution to make it work. But frankly, the easiest and classic way is to add the below entries into the /etc/profile.

export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8   


Another way could be ,
echo “LC_ALL=en_US.UTF-8 ” >> /etc/default/locale

If wondering which locale to add then below CLI will list all supported locale on linux box,

$ locale -a
C
C.UTF-8
de_CH.utf8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
POSIX
zh_CN.utf8
zh_SG.utf8


Will it cause any repercussions? I don't know. But at least on my machine this solved the problem and stopped giving "perl: warning: Setting locale failed." warning messages and till now everything seems to be going fine.

Update: Title text is updated to resolve the 'unparsable structured data' error

Note: We at TechSutram take our ethics very seriously. More information about it can be found here.
Mandar Pise Opinions expressed by techsutram contributors are their own. More details

Mandar is a seasoned software professional for more than a decade. He is Cloud, AI, IoT, Blockchain and Fintech enthusiast. He writes to benefit others from his experiences. His overall goal is to help people learn about the Cloud, AI, IoT, Blockchain and Fintech and the effects they will have economically and socially in the future.

No comments:

Post a Comment

    Your valuable comments are welcome. (Moderated)