Cannot set LC_CTYPE to default locale: No such file or directory
When ssh
into a production server, Debian, and noticed there is a warning or error as follows:
Terminal
manpath: can't set the locale; make sure $LC_* and $LANG are correct
mkyong@test-server:~$
Check the server’s locale; there are warning about the LC_CTYPE
and LC_ALL
variables.
Terminal
$ locale
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=en_US.UTF-8
LANGUAGE=
LC_CTYPE=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=
1. Solution (Linux): Reconfigure locales.
On Linux, try to reconfigure the locale to en_US.UTF-8
.
Terminal
$ sudo locale-gen "en_US.UTF-8"
Generating locales...
en_US.UTF-8... done
Generation complete.
$ sudo dpkg-reconfigure locales
Generating locales...
en_US.UTF-8... up-to-date
Generation complete.
2. Solution (macOS) : Terminal sets environment variables.
When we login over ssh
from macOS to Linux, the terminal default automatically sets environment variables.
In Terminal, clicks Terminal
-> Settings...
-> Profiles
-> Advanced tab
. There’s a checkbox for sets environment variables on startup, Uncheck it. Open a new terminal and log in via ssh again; the locale should be correct now.
Does not work
sudo dpkg-reconfigure locales
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = “en_US.UTF-8”,
LC_ALL = “en_US.UTF-8”,
LC_MEASUREMENT = “fr_FR.UTF-8”,
LC_PAPER = “fr_FR.UTF-8”,
LC_MONETARY = “fr_FR.UTF-8”,
LC_NAME = “fr_FR.UTF-8”,
LC_CTYPE = “en_US.UTF-8”,
LC_ADDRESS = “fr_FR.UTF-8”,
LC_NUMERIC = “fr_FR.UTF-8”,
LC_MESSAGES = “en_US.UTF-8”,
LC_TELEPHONE = “fr_FR.UTF-8”,
LC_IDENTIFICATION = “fr_FR.UTF-8”,
LC_TIME = “fr_FR.UTF-8”,
LANG = “en_US.UTF-8”
are supported and installed on your system.
perl: warning: Falling back to the standard locale (“C”).
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
/usr/sbin/dpkg-reconfigure: locales is broken or not fully installed
It has been a week I am on it… I go around circles….