Categories
Terminal Troubleshooting

Fixing “Warning: Failed to set locale category…”

▶ wget
Warning: Failed to set locale category LC_NUMERIC to en_MU.
Warning: Failed to set locale category LC_TIME to en_MU.
Warning: Failed to set locale category LC_COLLATE to en_MU.
Warning: Failed to set locale category LC_MONETARY to en_MU.
Warning: Failed to set locale category LC_MESSAGES to en_MU.
wget: missing URL
Usage: wget [OPTION]... [URL]...

Try `wget --help' for more options.

You often get this rather annoying warning in your terminal on a freshly installed operating system (or each time until you decide it’s annoying enough to be fixed). For example when you are using wget, your terminal will serve you these warnings. You have a configuration issue with your computer’s or server’s locale.

We’ll tackle this issue methodologically, instead of blindly copy/pasting the solution; we’ll be using the inbuilt locale command from the terminal to debug this issue.

The locale tool will give you information about the current locale environment or about all the available locales.

This warning is usually served because the locale you’re using, here en_MU, doesn’t exist in the list of locales present on your system. You can check the list using locale -a or even locale -a | grep en_MU to see if your locale is there. But if you’re googling this error and ended up here, it’s clearly because your locale isn’t in that list.

Let’s see what locales we currently have set:

▶ locale      
LANG=""
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=

To set the correct values, you should export some values in your ~/.bash_profile file or use the ~/.zshrc file if you use oh-my-zsh. After you open the required file with your favourite text editor, add the following two lines at the bottom:

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

Save the file, open a new terminal tab and run the locale command again:

▶ locale
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL="en_US.UTF-8"

Everything looks fine now. We can now run wget without getting these warnings anymore.

▶ wget
wget: missing URL
Usage: wget [OPTION]... [URL]...

Try `wget --help' for more options.