How double quotes are added in LC_COLLATE? - linux

On Centos 6.5, running locale produces:
LANG=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LC_NUMERIC=zh_CN.UTF-8
LC_TIME=zh_CN.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=zh_CN.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=zh_CN.UTF-8
LC_NAME=zh_CN.UTF-8
LC_ADDRESS=zh_CN.UTF-8
LC_TELEPHONE=zh_CN.UTF-8
LC_MEASUREMENT=zh_CN.UTF-8
LC_IDENTIFICATION=zh_CN.UTF-8
LC_ALL=
After running export LC_COLLATE="en_US.UTF-8", running locale produces:
LANG=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LC_NUMERIC=zh_CN.UTF-8
LC_TIME=zh_CN.UTF-8
LC_COLLATE=en_US.UTF-8
LC_MONETARY=zh_CN.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=zh_CN.UTF-8
LC_NAME=zh_CN.UTF-8
LC_ADDRESS=zh_CN.UTF-8
LC_TELEPHONE=zh_CN.UTF-8
LC_MEASUREMENT=zh_CN.UTF-8
LC_IDENTIFICATION=zh_CN.UTF-8
LC_ALL=
LC_COLLATE="en_US.UTF-8" becomes LC_COLLATE=en_US.UTF-8. Double quotes are lost. How LC_COLLATE is set to "en_US.UTF-8"? If I run export LC_COLLATE='"en_US.UTF-8"', there is the following error:
-bash: warning: setlocale: LC_COLLATE: cannot change locale ("en_US.UTF-8"): No such file or directory
-bash: warning: setlocale: LC_COLLATE: cannot change locale ("en_US.UTF-8")
How I can set LC_COLLATE to "en_US.UTF-8" using some commands?

Related

how to fix the locale when input gitlab-ctl reconfigure

When I input gitlab-ctl reconfigure, it shows:
gitlab-ctl reconfigure it shows DETAIL:
The database was initialized with LC_COLLATE "zh_CN.UTF-8",
which is not recognized by setlocale().
The system is centos7: how can I fix the problem?
The content of .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
and the content of profile
unset i
unset -f pathmunge
export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:$PKG_CONFIG_PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib64
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64/jre/bin/java
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
export M2_HOME=/usr/local/maven3
export PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin
export PATH=$PATH:/usr/local/gcc-linaro-4.9-2016.02-x86_64_arm-linux-gnueabihf/bin
export PATH=$PATH:/usr/local/mysql/bin
I also tried to install postgresql, when I login, it shows below.
[root#0c-5b-8f-27-9a-64 ~]# su - postgres
Last login: Tue Jun 22 14:30:01 CST 2021 on pts/0
-bash: warning: setlocale: LC_ALL: cannot change locale (zh_CN.UTF-8): Permission denied
-bash: warning: setlocale: LC_ALL: cannot change locale (zh_CN.UTF-8)
-bash: warning: setlocale: LC_ALL: cannot change locale (zh_CN.UTF-8)
-bash: export: `=': not a valid identifier
-bash: export: `en_US.UTF-8': not a valid identifier
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (zh_CN.UTF-8)
-bash: warning: setlocale: LC_ALL: cannot change locale (zh_CN.UTF-8)
-bash: export: `=': not a valid identifier
-bash: export: `en_US.UTF-8': not a valid identifier
Check if, as in this thread, you can regenerate the right locale
In your case, as in here:
localedef -i zh_CN -c -f UTF-8 zh_CN.UTF-8
export LANG=zh_CN.UTF-8
gitlab-ctl reconfigure
And change /etc/locale.conf to:
LANG=zh_CN.UTF-8
LC_COLLATE=zh_CN.UTF-8
See if the issue persists then.

How to set the result's encoding after runing find-dired?

OS info:
uname -r
4.5.5-300.fc24.x86_64
emacs --version
GNU Emacs 25.1.1
More info about emacs:
M-x eshell
locale
LANG=en_US.UTF-8
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=
I can not find the right answer via google.
How to solve this?
Try setting this variable:
(setq find-ls-option '("-exec ls -ldh {} +" . "-ldh"))
This should workaround the problem.
The actual problem might be with Emacs's terminal encoding, though. Try setting
(set-terminal-coding-system 'utf-8-unix)
and carefully inspecting LC_ALL, LC_CTYPE and LANG environment variables (inside Emacs, of course).

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.
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).
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.
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.
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.
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.
please try next:
localedef -i en_US -f UTF-8 en_US.UTF-8
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.
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/

Locale Error in centos

Every time I login to my CentOS 6 server through SSH I get this error
Can anyone please explain what does that error mean & how to fix?
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
The Fix:
Thanks for Millie Smith (https://stackoverflow.com/users/2850543/millie-smith) & http://linuxforums.org.uk/index.php?topic=10318.0
Using root user through ssh
Run these commands
vi /etc/environment
& add these lines:
LANG=en_US.utf-8
LC_ALL=en_US.utf-8
Before connecting to the host via SSH, you can set LC_ALL to C, e.g.
LC_ALL=C ssh user#example.com
I try yum reinstall glibc-common from there and #Seif Hatem's
method.
but it don not work.
you can use try this.
It works.
export LANG=en_US.UTF-8
export LC_CTYPE="en_US.UTF-8"
export LC_NUMERIC="en_US.UTF-8"
export LC_TIME="en_US.UTF-8"
export LC_COLLATE="en_US.UTF-8"
export LC_MONETARY="en_US.UTF-8"
export LC_MESSAGES="en_US.UTF-8"
export LC_PAPER="en_US.UTF-8"
export LC_NAME="en_US.UTF-8"
export LC_ADDRESS="en_US.UTF-8"
export LC_TELEPHONE="en_US.UTF-8"
export LC_MEASUREMENT="en_US.UTF-8"
export LC_IDENTIFICATION="en_US.UTF-8"
export LC_ALL=en_US.UTF-8
https://github.com/2creatives/vagrant-centos/issues/7

AWS ec2 en_US.UTF-8 issue

https://aws.amazon.com/amazon-linux-ami/2012.03-release-notes/
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8)
[ec2-user#ip-10-136-14-68 ~]$ vi ~/.bash_profile
[ec2-user#ip-10-136-14-68 ~]$
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export LC_CTYPE="en_US.UTF-8"
how do you solve this?
Another solution is to add these lines to /etc/environment
LANG=en_US.utf-8
LC_ALL=en_US.utf-8
The next time you log in the warning message should have disappeared.
Open your ssh_config file (in my case under Ubuntu it's located here : /etc/ssh/ssh_config), and comment this line:
SendEnv LANG LC_*
This means :
#SendEnv LANG LC_*

Resources