10
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

macOS Mojave 10.14 にアップデート後、iTerm2 で SSH したら文字化けした

Posted at

macOS Mojave 10.14 にアップデートしたら文字化けしたので調べました。

ターミナル

  • iTerm2 3.2.2beta3
    • その後、他の安定版や古いバージョンで試したところ再現
  • OS 付属の ターミナル では再現せず

LC_CTYPE がおかしい?

SSH 先

locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=ja_JP.UTF-8
LC_CTYPE=UTF-8
LC_NUMERIC="ja_JP.UTF-8"
LC_TIME=C
LC_COLLATE="ja_JP.UTF-8"
LC_MONETARY="ja_JP.UTF-8"
LC_MESSAGES=C
LC_PAPER="ja_JP.UTF-8"
LC_NAME="ja_JP.UTF-8"
LC_ADDRESS="ja_JP.UTF-8"
LC_TELEPHONE="ja_JP.UTF-8"
LC_MEASUREMENT="ja_JP.UTF-8"
LC_IDENTIFICATION="ja_JP.UTF-8"
LC_ALL=

ローカル(mac)

$ locale
LANG="ja_JP.UTF-8"
LC_COLLATE="ja_JP.UTF-8"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="ja_JP.UTF-8"
LC_NUMERIC="ja_JP.UTF-8"
LC_TIME="C"
LC_ALL=

LC_CTYPE="ja_JP.UTF-8" vim hoge とすると文字化けが解消

下記のいづれかで対応可能

  1. Preference > Profiles > Terminal > Envirionment
    • Set locale variables automatically のチェックを外す
  2. SSH 先の環境変数 LC_* を適当に設定する
  3. /etc/ssh/ssh_configSendEnv LANG LC_* しないようにする

なぜ起きた?

mojave が原因なのか、iTerm2が原因なのか不明ですが、バグレポートは上がっているみたいです。なので近々iTerm2 側で対応がされるかもしれません。

https://gitlab.com/gnachman/iterm2/issues/5478

10
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?