Error message when starting vim: "Failed to set locale category LC_NUMERIC to en_CH" (or en_BR, en_RU & LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES)

MacosVimTerminalLocaleLocal

Macos Problem Overview


I freshly installed vim (Vi IMproved 8.1) as a text editor on my MacOS 10.14.5 with Homebrew. Each time that I run vim I get this error message:

Warning: Failed to set locale category LC_NUMERIC to en_CH.
Warning: Failed to set locale category LC_TIME to en_CH.
Warning: Failed to set locale category LC_COLLATE to en_CH.
Warning: Failed to set locale category LC_MONETARY to en_CH.
Warning: Failed to set locale category LC_MESSAGES to en_CH.

I have to click ENTER and it works but I would like to get rid of that error message.

I saw a similar message on that link

How can I get rid of this error message?

Macos Solutions


Solution 1 - Macos

First, access your .bash_profile file by typing the following (using vim as text editor):

vim ~/.bash_profile

Inside the file .bash_profile, insert the following line:

export LC_ALL=en_US.UTF-8

Note, however, that newer versions of macOS ship with zsh instead of bash as the default shell. If this is the case with your Mac, you will have to edit ~/.zshrc instead of ~/.bash_profile.

Restart the Terminal or source ~/.zshrc or source ~/.bash_profile and launch vim again: the error message should have disappeared.

Thanks @geoyws - George Yong and pkropachev Pavel Kropachev for their answer found there, thanks @bk2204 for the hints in the other answer

Solution 2 - Macos

In Short: your macOS/Unix/Linux doesn't have the default configuration of locales and you should connect it when your bash restarted. Therefore the solution is to update config files and reload it (In my example the language would be English and the default encoding would be UTF-8):

If you use oh-my-zsh:

vim ~/.zshrc
export LC_ALL=en_US.UTF-8

If you use fish-shell:

vim ~/.config/fish/config.fish
set -x LC_ALL en_US.UTF-8

else (default):

vim ~/.bash_profile 
#OR (vim  ~/.bashrc) 
export LC_ALL=en_US.UTF-8

Solution 3 - Macos

if you use zsh, you could

vim ~/.zshrc

and uncomment next line:

export LC_ALL=en_US.UTF-8

Solution 4 - Macos

if you use fish, you could

vim ~/.config/fish/config.fish
set -x LC_ALL en_US.UTF-8

Solution 5 - Macos

Somehow your locale is set to "en_CH". This locale is for English as spoken in Switzerland, but on your system, that isn't a valid locale. Generally, locales also contain a character set to use, such as the "UTF-8" in "en_US.UTF-8", which is also absent here.

It's likely that something in your shell configuration is setting these values, because macOS typically does not set these specific values; instead, it sets the LANG environment variable, and it always uses UTF-8 locales. You should check either your .bashrc and .bash_profile settings or possibly your .zshenv, .zshrc, and .zprofile settings and change any LANG, LC_ALL, or other LC_* variable you may have set.

As a note, I'm not aware of any system that has an en_CH locale; typically there will only be locales for languages that are commonly spoken in the country or region (often, but not always, official languages). For example, while there are certainly many speakers of French in the United States, systems typically do not provide an fr_US.UTF-8 locale, because there are not enough speakers to have established norms for localization. You may need to pick another English locale, such as "en_GB.UTF-8" or "en_US.UTF-8" that is close enough for your needs, or set individual "LC" variables depending on which settings you want to pick and chooise.

Solution 6 - Macos

Alternatively if you can't create your specific locale (e.g. with rootless MacOS*) set an already installed locale.

vim ~/.bash_profile
export LC_ALL=C

I found that the locale C was available on all systems I accessed, including ones via SSH. You can list available locales via locale -a.

*And don't want to go the route of messing with SIP

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionecjbView Question on Stackoverflow
Solution 1 - MacosecjbView Answer on Stackoverflow
Solution 2 - MacosavivamgView Answer on Stackoverflow
Solution 3 - MacosLeahView Answer on Stackoverflow
Solution 4 - MacosJim HanView Answer on Stackoverflow
Solution 5 - Macosbk2204View Answer on Stackoverflow
Solution 6 - MacosCruiserView Answer on Stackoverflow