解決 Warp terminal ssh 到 server 時的 locale warning

我也不知知道為什麼我用 Warp,他主推的 AI 功能我也是沒用過幾次。看來這就是朋友推薦的力量吧,剛好被推薦的那陣子重裝了電腦想說用用看就一直用到現在懶得換。

要說有什麼特別好或特別壞的嗎?以我的使用方式,用起來跟以前用 iTerm2 的感覺是差不多的。

locale warning

在 macOS 上用 Warp termnial 連到 server 的時候就會出現這樣的訊息:

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
_____________________________________________________________________
WARNING! Your environment specifies an invalid locale.
 The unknown environment variables are:
   LC_CTYPE=UTF-8 LC_ALL=
 This can affect your user experience significantly, including the
 ability to manage packages. You may install the locales by running:

 sudo dpkg-reconfigure locales

 and select the missing language. Alternatively, you can install the
 locales-all package:

 sudo apt-get install locales-all

To disable this message for all users, run:
   sudo touch /var/lib/cloud/instance/locale-check.skip
_____________________________________________________________________

或是這樣的訊息:

bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory

這是因為在 ssh 的時候也會把 macOS 的 local environments 也一起傳過去。

macOS 的 LC_CTYPE 預設是 UTF-8,與 Debian 的格式不一樣(例如: en_US.UTF-8, 所以 Debian 不認得。

解決方法

知道原因後,解決方法就是以傳入 Debian 看得懂的 locale 或是 ssh 的時候 server 那邊不要理 macOS 傳了什麼過去。

ssh 時直接傳

這個最直接:

> LC_CTYPE=C.UTF-8 ssh <remote>

把 LC_CTYPE 加到 .zshrc

export LC_CTYPE=C.UTF-8

server 直接忽略這個值

在 server 的 /etc/ssh/sshd_configAcceptEnv:

# Allow client to pass locale and color environment variables
AcceptEnv LANG LC_* COLORTERM NO_COLOR

然後把它 comment 掉,不過像是我發現我有經過 Tailscale ssh 的 server 貌似這個不會被理睬,我也不是很確定。

結論

目前是使用在 .zshrcLC_CTYPE 來解決~

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *