Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)

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?

like image 558
ecjb Avatar asked Jun 22 '19 16:06

ecjb


3 Answers

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

like image 199
ecjb Avatar answered Nov 11 '22 18:11

ecjb


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
like image 21
avivamg Avatar answered Nov 11 '22 17:11

avivamg


if you use zsh, you could

vim ~/.zshrc

and uncomment next line:

export LC_ALL=en_US.UTF-8
like image 10
Leah Avatar answered Nov 11 '22 19:11

Leah