Warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory

In vscode i was getting the error while launching the terminal:
warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory

check the issue on github : https://gist.github.com/jampajeen/841d4eed4da3e6c758bf

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. I have given my system specs below for your reference.
image

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.

This is definitely not the proper solution.
This proposed “solution” at an old Centos topic is a bad practice for Archlinux.
Setting LC_ALL is for troubleshooting only, while setting it permanently is advised against in Archwiki.
This should also be noticed clearly for future readers.

A proper solution is to find how to properly set locale env vars, and in case there is a bug in a package, it should be reported upstream for a fix.

I don’t use vscode, so I can’t check for more info. It could be either vscode, or the used terminal need proper configuration, or system and/or user locale should be properly configured. This issue is not uncommon, and I am sure there are similar topics that you might find with a forum search.

If you want some assistance, please, post output of these commands:

locale
localectl
grep . /etc/locale.conf /etc/vconsole.conf
grep -v "^#" /etc/locale.gen
ls -l "$HOME"/.config | grep locale
inxi -SIMaz
2 Likes

Hello, in my case I still have not been able to find a solution, I share the output of the commands:

[root@f2cf4eea4db4 ~]# locale
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
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=

[root@f2cf4eea4db4 ~]# localectl
System Locale: LANG=en_US.UTF-8
VC Keymap: us
X11 Layout: us

[root@f2cf4eea4db4 ~]# grep . /etc/locale.conf /etc/vconsole.conf
/etc/locale.conf:LANG=“en_US.UTF-8”
/etc/vconsole.conf:KEYMAP=“us”
/etc/vconsole.conf:FONT=“eurlatgr”

[root@f2cf4eea4db4 ~]# grep -v “^#” /etc/locale.gen
grep: /etc/locale.gen: No such file or directory

[root@f2cf4eea4db4 ~]# ls -l “$HOME”/.config | grep locale
ls: cannot access ‘/root/.config’: No such file or directory

[root@f2cf4eea4db4 ~]# inxi -SIMaz
-bash: inxi: command not found

Check if you have /etc/default/keyboard and delete it or edit it properly. It is installed by Calamares installer, and is not suggested in Arch systems, but interferes when it exists.
You may want to read this similar topic.

If it still doesn’t work properly, please, create a new topic for your issue, since this one is already solved.