Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I got warning setlocale LC_CTYPE when I ssh connect to vagrant centos 6

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.

like image 775
Hien Nguyen Avatar asked Feb 25 '16 08:02

Hien Nguyen


3 Answers

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).

like image 115
Dominik Avatar answered Oct 07 '22 10:10

Dominik


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.

like image 33
Slava Avatar answered Oct 07 '22 12:10

Slava


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.

like image 5
kenorb Avatar answered Oct 07 '22 10:10

kenorb