Reputation: 589
I'm a beginner with vagrant. I try to create a virtual machine (cent os 6) on my computer with vagrant. When I run vagrant ssh, it prints this warning:
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
When I run locale
, I get this:
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
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=
I searched for an hour but I still cannot fix that.
Upvotes: 32
Views: 51908
Reputation: 11
SOLVED: I had this error on Amazon ECS Linux 2:
warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
warning: setlocale: LC_COLLATE: cannot change locale (en_US.UTF-8): No such file or directory
warning: setlocale: LC_MESSAGES: cannot change locale (en_US.UTF-8): No such file or directory
warning: setlocale: LC_NUMERIC: cannot change locale (en_US.UTF-8): No such file or directory
warning: setlocale: LC_TIME: cannot change locale (en_US.UTF-8): No such file or directory
manpath: can't set the locale; make sure $LC_* and $LANG are correct
After reading a bunch of Stack Overflow posts and articles, I was able to understand that the problem relates to missing locale/language packages and fixed it as described below.
REASON: I had been deleting packages while trying to save space on a Cloud9/T3 instance. (Seems I deleted too much! Whoops.)
SOLUTION:
Install the following packages:
then update your local definitions, as follows:
sudo yum -y install glibc-locale-source glibc-langpack-en
sudo localedef -i en_US -f UTF-8 en_US.UTF-8
Thanks to https://stackoverflow.com/questions/58304278/how-to-fix-character-map-file-utf-8-not-found
Worked for me! Hope this helps you.
Upvotes: 1
Reputation: 12356
I'm using macOS. I put the following contents into my ~/.ssh/config
:
Host *
SetEnv LC_CTYPE=
It seems to me the least intrusive way to alter ssh configuration.
Upvotes: 3
Reputation: 674
For those getting this error in MacOS: Open /etc/ssh/ssh_config file (in any editor you prefer, I have used vi editor in the example)
sudo vi /etc/ssh/ssh_config
(enter sudo password)
in this file, comment out the line below:
SendEnv LANG LC_*
(use # for commenting: #SendEnv LANG LC_*
)
close the file. Close and reopen the terminal and try the ssh command again.
For a detailed understanding of the issue you can check this tech blog: https://www.cyberciti.biz/faq/os-x-terminal-bash-warning-setlocale-lc_ctype-cannot-change-locale/
Upvotes: 0
Reputation: 3493
This might be caused by your terminal settings.
For iTerm2, uncheck this setting:
Profiles -> Terminal -> "Set locale variables automatically"
.
Context: In case you are working on a shared node where you can't modify locale settings, the warning might be caused by your terminal trying (and failing) to change locale.
Upvotes: 6
Reputation: 166795
You can set LC_ALL
to C
, e.g.
export LC_ALL=C
or prefix before connecting to your VM:
LC_ALL=C ssh vagrant@localhost
Note: You can consider also setting SetEnv
for your SSH config (man ssh_config
) as explained below.
To make it permanent, you can add the following rule in your ~/.ssh/config
:
Host *
SetEnv LC_ALL=C
Assuming your server got the following line in /etc/ssh/sshd_config
:
AcceptEnv LANG LC_*
Check also: man ssh_config
and man sshd_config
.
Upvotes: 10
Reputation: 2551
For CentOS or Amazon AMI Linux, add these lines to /etc/environment
(create it, if it doesn't exist):
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8
To edit this file via SSH console, try
sudo nano /etc/environment
Edit
For Debian-related distributions (Ubuntu, etc.), you should check that /etc/default/locale
is empty. That's the outcome of choosing None in dpkg-reconfigure locales
which is suggested if users access via SSH (see Debian Wiki).
/etc/environment
is deprecated since Debian Lenny (5.0).
Upvotes: 80
Reputation: 680
In my case, on Slackware64 14.1 I got the error:
-bash: warning: setlocale: LC_ALL: cannot change locale (en_DK.UTF-8)
It turned out to be missing glibc packages.
Installing the packages:
glibc-2.17-x86_64-11_slack14.1
glibc-i18n-2.17-x86_64-11_slack14.1
Solved the problem.
My /etc/profile.d/lang.sh contains:
export LANG=en_DK.UTF-8
export LANGUAGE=en_DK.UTF-8
export LC_ALL=en_DK.UTF-8
export LC_COLLATE=C
Enjoy.
Upvotes: 3
Reputation: 97
Under root in bashrc add following :
vi /root/.bashrc
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
And reboot your system afterwards.
Upvotes: 7