Skip to content

Instantly share code, notes, and snippets.

@jampajeen
Created November 21, 2015 13:02
Show Gist options
  • Save jampajeen/841d4eed4da3e6c758bf to your computer and use it in GitHub Desktop.
Save jampajeen/841d4eed4da3e6c758bf to your computer and use it in GitHub Desktop.
Centos warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
vi /etc/environment
add these lines...
LANG=en_US.utf-8
LC_ALL=en_US.utf-8
@deivide
Copy link

deivide commented Sep 1, 2022

+1

@YevheniiPokhvalii
Copy link

Don't forget to install glibc-langpack-en if it's missing.

@vivekkum-ar
Copy link

run command : sudo nano /etc/environment
add the below two lines
LANG="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
save- ctrl+o
confirm save
exit nano with- ctrl+x
run command : source /etc/environment

You should be good to go. But i discovered that it needs to reboot on arch given my system specs below for your reference.
image

@YevheniiPokhvalii
Copy link

run command : sudo nano /etc/environment add the below two lines LANG="en_US.UTF-8" LC_ALL="en_US.UTF-8" save- ctrl+o confirm save exit nano with- ctrl+x run command : source /etc/environment

You should be good to go. But i discovered that it needs to reboot on arch given my system specs below for your reference. image

It will not work, if you do not have glibc-langpack installed for the required language. English in our case glibc-langpack-en

@meetsohail
Copy link

Thanks

@EinsDreiDreiSiebenX
Copy link

@joshgies-xad
Copy link

joshgies-xad commented May 1, 2023

+1 for mosamadi solution. It resolved it for me on Amazon Linux 2.
Thank you @mosamadi !

[joshgies@ec2-54-226-27-205 payments-np101 ~]$ sudo su -
Last login: Mon May 1 18:57:54 UTC 2023 on pts/0
-bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
-bash: warning: setlocale: LC_COLLATE: cannot change locale (en_US.UTF-8): No such file or directory
-bash: warning: setlocale: LC_MESSAGES: cannot change locale (en_US.UTF-8): No such file or directory
-bash: warning: setlocale: LC_NUMERIC: cannot change locale (en_US.UTF-8): No such file or directory
-bash: warning: setlocale: LC_TIME: cannot change locale (en_US.UTF-8): No such file or directory
[root@ec2-54-226-27-205 payments-np101 ~]$ exit
logout
[joshgies@ec2-54-226-27-205 payments-np101 ~]$ sudo -s
[root@ec2-54-226-27-205 payments-np101 joshgies]$
[root@ec2-54-226-27-205 payments-np101 joshgies]$ man localedef
man: can't set the locale; make sure $LC_* and $LANG are correct
[root@ec2-54-226-27-205 payments-np101 joshgies]$ sudo localedef -i en_US -f UTF-8 en_US.UTF-8
[root@ec2-54-226-27-205 payments-np101 joshgies]$ exit
exit
[joshgies@ec2-54-226-27-205 payments-np101 ~]$ sudo su -
Last login: Mon May 1 18:58:02 UTC 2023 on pts/0

@ans1genie
Copy link

adding that to your .profile (.zprofile, .. or somilar) is enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment