How to fix “perl: warning: Setting locale failed”

There’s a pretty common issue with locales in Ubuntu that brings up a nasty warning message about “Setting locale failed”.

You can use the following line to resolve it:

sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8

This sets the default locale to en_US.UTF-8.