TL;DR:
Setting the LC_CTYPE
environment variable to ja_JP.UTF-8
fixed it.
When I start vim, it crashes with the following error.
% vim
Fatal Python error: config_get_locale_encoding: failed to get the locale encoding: nl_langinfo(CODESET) failed
Python runtime state: preinitialized
A search in the error message found a thread in the Python bug tracker. https://bugs.python.org/issue39397
A mistake in setting the locale has been pointed out. You are also advised to remove the LC_CTYPE
environment variable. The reporter himself seems to have solved the problem by removing the LANG
environment variable.
Check your environment.
% locale
LANG="ja_JP.UTF-8"
LC_COLLATE="ja_JP.UTF-8"
LC_CTYPE="ja_JP.UTF-8"
LC_MESSAGES="ja_JP.UTF-8"
LC_MONETARY="ja_JP.UTF-8"
LC_NUMERIC="ja_JP.UTF-8"
LC_TIME="ja_JP.UTF-8"
LC_ALL=
% echo $LANG
ja_JP.UTF-8
% env | grep '^LC_ALL=' #undefined
% env | grep '^LC_CTYPE=' #undefined
The LANG
environment variable is set. The LC_CTYPE
environment variable is not set, so the locale
command sets the locale setting LC_CTYPE
to ja_JP.UTF-8
.
I don't want to change the setting of the LANG
environment variable in my environment, so look for another solution.
Here, I investigated the meaning of nl_langinfo (CODESET)
, which seems to be the location where the error occurred. https://linuxjm.osdn.jp/html/LDP_man-pages/man3/nl_langinfo.3.html
The nl_langinfo () function provides a more flexible way to access locale information than localeconv (3). You can query individual or additional elements of the locale category. … CODESET (LC_CTYPE) Returns a string indicating the character encoding name used in the selected locale.
nl_langinfo (CODESET)
seems to be related to the locale setting LC_CTYPE
. Its value should be equal to the value of the LC_CTYPE
environment variable (for the LC_ALL
environment variable if undefined, or for the LANG
environment variable if it is also undefined). In my environment, it should be ja_JP.UTF-8
, which is the same as the value of the LANG
environment variable, but it seems that the acquisition is not successful.
Try setting the LC_CTYPE
environment variable to ja_JP.UTF-8
.
% export LC_CTYPE=ja_JP.UTF-8
% vim
Vim should now start without any problems.
Vim
% brew info vim
vim: stable 8.2.0654 (bottled), HEAD
Vi 'workalike' with many additional features
https://www.vim.org/
Conflicts with:
ex-vi (because vim and ex-vi both install bin/ex and bin/view)
macvim (because vim and macvim both install vi* binaries)
/usr/local/Cellar/vim/8.2.0654 (1,888 files, 32.6MB) *
Poured from bottle on 2020-05-02 at 10:16:41
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/vim.rb
==> Dependencies
Required: gettext ✔, lua ✔, perl ✔, [email protected] ✔, ruby ✔
% grep '^Plug ' .vimrc
Plug 'Shougo/deoplete.nvim' " |deoplete_nvim|
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
The deoplete.nvim plugin depends on Python 3. This plugin seems to crash trying to load Python 3.
Python
% brew info [email protected]
[email protected]: stable 3.8.2 (bottled) [keg-only]
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/[email protected]/3.8.2 (4,196 files, 64MB)
Poured from bottle on 2020-03-16 at 14:48:28
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/[email protected]
macOS
% sw_vers
ProductName: Mac OS X
ProductVersion: 10.15.3
BuildVersion: 19D76
Recommended Posts