Skip to content

Instantly share code, notes, and snippets.

@jampajeen
Created November 21, 2015 13:02
Show Gist options
  • Star 52 You must be signed in to star a gist
  • Fork 17 You must be signed in to fork a gist
  • 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
@membphis
Copy link

Thanks +1

@kaungmyatsoe
Copy link

Thanks

@samma89
Copy link

samma89 commented Jan 29, 2017

+1 Thanks.

@PENGZhaoqing
Copy link

Thanks

@23Pstars
Copy link

+1

@hannemario
Copy link

+1

@adieuadieu
Copy link

Cheers for this.

@pilhoon
Copy link

pilhoon commented Mar 20, 2017

+1

@hugotavares
Copy link

+1

@ZhukV
Copy link

ZhukV commented Nov 4, 2017

+1

@ibnusulaiman83
Copy link

share my solutions for Centos 7

sudo nano /etc/environment

LANG="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"

Ctrl + X > Yes >Enter

sudo reboot

@princealikhan
Copy link

+1

@caf3babe
Copy link

Thanks mate. Worked like a charm.
Do you know the root cause of this warning ?

@adwski
Copy link

adwski commented Aug 3, 2020

Thanks!

@AlternativeYeah
Copy link

Thanks!

@TiigerChayaphol
Copy link

Thanks!

@mosamadi
Copy link

mosamadi commented May 3, 2021

I am using AWS Linux and this was fix my issue:
sudo localedef -i en_US -f UTF-8 en_US.UTF-8

@francotel
Copy link

In my case I disable "set locale variables automatically" from my terminal preferences and It's ok

@datavisorchengpeng
Copy link

now working

@aankittcoolest
Copy link

Thank you!

@gdiazmez
Copy link

works, thanks!

@DAIHAITANG
Copy link

thank you. fix my problem.

@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