[Raspberry Pi] perl の locale 警告が出る場合2

以前 Raspberry Pi で perl の locale 警告が出るときの対処法について書いた。

[Raspberry Pi] perl の locale 警告が出る場合|with a Christian Wife|note
https://note.com/wacw/n/naf05c1feadaa

最近新しくインストールした Raspberry Pi OS でも同じく locale の警告が出た。

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

上記リンクの方法で解決しようとしたが変わらなかった。そこで少し方法を変えてみた。

環境:Raspberry Pi 3 Model B、Raspbian Buster

今回は locale を en_US.UTF-8 にする。

(1)以下のコマンドを実行。

$ nano ~/.bashrc

(2)先ほどの locale コマンドで、空欄もしくは en_GB.UTF-8 になっている部分を変更するため、以下を追記、保存する。

export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8

(3)以下のコマンドを実行。

$ sudo locale-gen
$ sudo locale-gen en_US.UTF-8

$ sudo locale-gen は不要かもしれない。)

(2)以下のコマンドを実行。

$ sudo dpkg-reconfigure locales

Locales to be generated で en_US.UTF-8 UTF-8 をスペースキーで選択、OK。

Default locale を選択するダイアログが出るので en_US.UTF-8 を選択、OK。

(3)再起動。

これで locale 警告が出なくなった。

参考:
Raspberry Piのlocale settingsでWarningが出るのを解消してnodebrewを使う – Qiita
https://qiita.com/n0bisuke/items/3a1965e3f74d2971e71e