Agile FAQs
  About   Slides   Home  

Managed Chaos
Naresh Jain's Random Thoughts on Software Development and Adventure Sports
RSS Feed
Recent Thoughts
Recent Comments

Fixing Perl Warning: Setting locale failed on Mac OS X Mavericks

I use SSH to connect to my servers for executing various deployment and monitoring scripts. Of late, whenever I ran my scripts, I kept getting this annoying perl warning:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

At first, I thought this must be due to some changes on my server. So I tried to set the LANG environment variable in bash on the server. No luck!

Later I realised, it has to do with my recent upgrade to Mac OS X Mavericks. Turns out that if you are using SSH, there are 2 variables which need to be set on your local machine, which gets passes down to your sever when you connect via SSH.

After adding the following lines to ~/.bash_profile on my local machine, the warning went away:

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

    Awesome! Thanks a lot.

  • Patrick Kaiser

    thanks! worked for me!

  • Miguel Angel Navarro

    Thank you for posting

  • TheUnF

    As root you can add these lines at the end of /etc/profile and will work with all users 😉

  • carlesandres

    Your help propagates through the years! I just fixed a similar error thanks to your article

  • Sergiu

    Your solution saved my day!

  • I work in MacOS Sierra and the only thing that worked for me was unchecking “Set local variables on startup” in the Advance tab in Terminal preference. Solution on this page:

    Licensed under
Creative Commons License