Fix 'Setting Locale Failed' Warnings in Ubuntu

Takashi Yoshida bio photo By Takashi Yoshida

I have been getting warnings like below when I upgrade packages with aptitude.

takashi@kalmiya:~$ sudo aptitude full-upgrade
[sudo] password for takashi:
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LC_TYPE = "UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_TYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: NO such file or directory

Despite my previous attempt to fix this before, warnings just did not go away. After digging around a bit more, disabling SendEnv LANG LC_* from /etc/ssh/ssh_config stopped the warnings from appearing.

# Site-wide defaults for some commonly used options.  For a comprehensive
# list of available options, their meanings and defaults, please see the
# ssh_config(5) man page.

Host *
# 2017-01-16 TY: Disable this to prevent "warning: Setting locale failed" related
# warnings. See http://qiita.com/networkelements/items/12e2448b75f7ff057139
#        SendEnv LANG LC_*

Sources: