perl: warning: Setting locale failed error

Created by Bent Petersen, Modified on Tue, 12 Mar, 2024 at 8:04 PM by Bent Petersen

Often when running Perl you will see error messages like this:


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").


The error message you're seeing is related to the configuration of locale settings on your Unix/Linux system. Locale settings determine the language and regional settings for your applications, affecting things like date formats, the first day of the week, and character encoding. The error indicates that Perl is unable to use the specified locale settings because they are not properly configured or installed on your system. 


The step to resolve the issue is done by setting environment variables in your shell profile file (e.g., .bash_profile, .bashrc, .zshrc, etc.).


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


After adding these lines, you will need to log out and log back in for the changes to take effect, or you can source the profile file directly using a command like source ~/.bashrc.



Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article