localeが足りなくてmcomixが起動しなくなっていた

mcomix が起動しなくなりました.こないだのエンバグ?と思ったけど

エラーが違う.

$ mcomix
Traceback (most recent call last):
  File "/usr/bin/mcomix", line 11, in <module>
    load_entry_point('mcomix==1.2.1', 'console_scripts', 'mcomix')()
  File "/usr/lib/python2.7/dist-packages/mcomix/run.py", line 127, in run
    i18n.install_gettext()
  File "/usr/lib/python2.7/dist-packages/mcomix/i18n.py", line 71, in install_gettext
    locale.setlocale(locale.LC_ALL, '')
  File "/usr/lib/python2.7/locale.py", line 581, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

localeぽいので適当に指定してみると起動.

$ LC_ALL=C mcomix

しかし,C だと日本語ファイル名などでエラーとなる.

UnicodeEncodeError: 'ascii' codec can't encode characters in position 25-27: ordinal not in range(128)
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/mcomix/file_chooser_base_dialog.py", line 215, in _response
    if os.path.isdir(path):
  File "/usr/lib/python2.7/genericpath.py", line 49, in isdir
    st = os.stat(s)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 25-27: ordinal not in range(128)

en_US.UTF-8 だととりあえず利用できるけど,ja_JP.UTF-8 とかで日本語を指定すると……うまく行かない?

$ export LC_ALL=ja_JP.UTF-8 mcomix
bash: warning: setlocale: LC_ALL: cannot change locale (ja_JP.UTF-8)

localeを確認するとインストール時に設定していたつもりの ja_JP.UTF-8 がありません.

$ grep -v ^# /etc/locale.gen |uniq

en_US.UTF-8 UTF-8

/etc/locale.gen を編集して,ja_JP.UTF-8 のコメントを外して locale-gen コマンドで生成したら動くようになりました.

$ sudo git diff HEAD~~ /etc/locale.gen
diff --git a/locale.gen b/locale.gen
index c432a9a..afb6141 100644
--- a/locale.gen
+++ b/locale.gen
@@ -287,7 +287,7 @@ en_US.UTF-8 UTF-8
 # it_IT@euro ISO-8859-15
 # iu_CA UTF-8
 # ja_JP.EUC-JP EUC-JP
-# ja_JP.UTF-8 UTF-8
+ja_JP.UTF-8 UTF-8
 # ka_GE GEORGIAN-PS
 # ka_GE.UTF-8 UTF-8
 # kab_DZ UTF-8
$ sudo locale-gen
Generating locales (this might take a while)...
  en_US.UTF-8... done
  ja_JP.UTF-8... done
Generation complete.
環境
$ dpkg-query -W locales mcomix
locales 2.29-1
mcomix  1.2.1-1.1
$ lsb_release -dr
Description:    Debian GNU/Linux bullseye/sid
Release:        unstable
$ uname -m
x86_64

コメントを残す

メールアドレスが公開されることはありません。 ※ が付いている欄は必須項目です

Your post must include a link to this post.

How does this work?
Write a response on your own website and include a link to this post. Then submit your response’s URL here. Your response may appear here after moderation. To update or remove it, edit or delete your original post and submit the same URL again. Learn more about Webmentions.