ubuntu update to 18.04 error found when loading /etc/profile cannot set LC_CTYPE, LC_MESSAGES, LC_ALL to default - locale

After updating from ubuntu 16.04 to 18.04 I receive the following warning: error found when loading /etc/profile cannot set LC_CTYPE to default locale. The warning message also lists LC_MESSAGES and LC_ALL as having the same problem.
Here is my /etc/profile
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ "${PS1-}" ]; then
if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then
# The file bash.bashrc already sets the default PS1.
# PS1='\h:\w\$ '
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
else
if [ "`id -u`" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
when I tried ran sudo dpkg-reconfigure locales, it returns...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = "en_US.UTI-8",
LC_CTYPE = "en_US.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/bin/locale: Cannot set LC_CTYPE to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_MESSAGES to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_ALL to default locale: No such file or directory
locales-all installed, skipping locales generation
*** update-locale: Error: invalid locale settings: LANG=en_US.UTF-8 LC_ALL="en_US.UTI-8" LC_CTYPE="en_US.UTF-8"
I tried the following:
sudo locale-gen
[sudo] password for go:
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Generating locales (this might take a while)...
en_AG.UTF-8... done
en_AU.UTF-8... done
en_BW.UTF-8... done
en_CA.UTF-8... done
en_DK.UTF-8... done
en_GB.UTF-8... done
en_HK.UTF-8... done
en_IE.UTF-8... done
en_IL.UTF-8... done
en_IN.UTF-8... done
en_NG.UTF-8... done
en_NZ.UTF-8... done
en_PH.UTF-8... done
en_SG.UTF-8... done
en_US.UTF-8... done
en_ZA.UTF-8... done
en_ZM.UTF-8... done
en_ZW.UTF-8... done
Generation complete.
go#go-Aspire-TC-705:~$ sudo dpkg-reconfigure locales
locales-all installed, skipping locales generation
*** update-locale: Error: invalid locale settings: LANG=en_US.UTF-8 LC_CTYPE="en_US.UTF-8" LC_ALL="en_US.UTI-8"
I now can run a program that required locale, but the update-locale complains about invalid locale settings.
I'm over my head here. Please help.

After looking at the last Error message listed in my question, I noticed that LC_ALL was being set to LC_ALL="en_US.UTI-8". I edited the /etc/default/locale and changed the UTI to UTF and now everything appears to be working. I'm not 100% sure that the locale-gen command assigned LC_ALL to UTI... I don't believe I did that.
In any event my solution is sudo locale-gen, edit the /etc/default/locale to
LC_CTYPE="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
#LANG="en_US.UTF-8"
and problem solved.

I had an issue similar to this along with multiple others, my locale was all jacked up, autocompletion was haywire, dpkg was throwing errors on installs. couldnt get anthing to change by unset or updating locale the problem was missing directory
/usr/lib/locale/locale.archive
made sure default locale file
/etc/default/locale
was correct then ran sudo locale-gen and it updated everything correctly

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.

linux input messed up

I was trying to do a cat command on a txt file, then things got messed up.
For example, when I type "[", I got "Ä" displayed. How to revert it back?
This is redhat linux 7. Some more info below.
-bash-4.2$ localectl status
System Locale: LANG=en_US.UTF-8
VC Keymap: us
X11 Layout: n/a
-bash-4.2$ cat /etc/profile.d/lang.sh
# /etc/profile.d/lang.sh - set i18n stuff
sourced=0
if Ä -n "$LANG" Å; then
saved_lang="$LANG"
Ä -f "$HOME/.i18n" Å && . "$HOME/.i18n" && sourced=1
LANG="$saved_lang"
unset saved_lang
else
for langfile in /etc/locale.conf "$HOME/.i18n" ; do
Ä -f $langfile Å && . $langfile && sourced=1
done
fi

manpath: can't set the locale; make sure $LC_* and $LANG are correct

I just installed terminator terminal emulator on my linux mint. for some reason I don't understand, it sets my password to some of the locale options. I've tried several things but they only offer a temporary fix. each time I open the terminal, it resets the locale options to my password.
LANG=koldenod19*
LANGUAGE=
LC_CTYPE="mypassword"
LC_NUMERIC=om_KE.UTF-8
LC_TIME="mypassword"
LC_COLLATE="mypassword"
LC_MONETARY=om_KE.UTF-8
LC_MESSAGES="mypassword"
LC_PAPER=om_KE.UTF-8
LC_NAME=om_KE.UTF-8
LC_ADDRESS=om_KE.UTF-8
LC_TELEPHONE=om_KE.UTF-8
LC_MEASUREMENT=om_KE.UTF-8
LC_IDENTIFICATION=om_KE.UTF-8
LC_ALL=
I've tried using sudo dpkg-reconfigure locales and export LC_ALL="eo_US.utf8" and the problem still persists.
Try this https://gist.github.com/SimonSun1988/2ef7db45e46b889783647d941ec15e4d
sudo locale-gen "en_US.UTF-8"
sudo dpkg-reconfigure locales
and in file /etc/default/locale add line LC_ALL="en_US.UTF-8" and relogin to your server.
For CentOS this worked for me.
Add these lines to /etc/environment
LANG=en_US.utf-8
LC_ALL=en_US.utf-8
Edit your /etc/locale.gen then uncomment the following line:
en_GB.UTF-8 UTF-8
Run:
sudo locale-gen en_GB.UTF-8 UTF-8
sudo update-locale en_GB.UTF-8 UTF-8
export LANGUAGE=en_GB.UTF-8
export LC_ALL=en_GB.UTF-8
Verify it;
locale
You may get:
LANG=en_GB.UTF-8
LANGUAGE=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=en_GB.UTF-8
And Done !!!
If you are having this problem on CentOS, follow this example because nothing else worked for me.
The command localedef -i en_US -f UTF-8 en_US.UTF-8 fixes the problem, but may lead to another one:
[error] character map file UTF-8' not found: No such file or directory
default character map file ANSI_X3.4-1968' not found: No such file or directory.
Finally, executing yum -y install glibc-locale-source prior to localedef -i en_US -f UTF-8 en_US.UTF-8 installs the missing files and changes back the locale.
Now locale reports again:
LANG=en_US
.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
(...)
LC_ALL=
Hope that helps someone out there.
RedHat: Change /etc/locale.conf to
LANG=en_US.UTF-8
LC_ALL=en_US.utf-8
If you encounter this issue and are working based on Docker.
Install locales first and then generate locale.
apt install locales
locale-gen en_US.UTF-8
This worked for me :
echo "LC_ALL=en_US.UTF-8" >> /etc/environment
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
locale-gen en_US.UTF-8
Source

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/

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