I am getting this message every time I do something like starting or stopping a service.
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US:en",
LC_ALL = (unset),
LC_MESSAGES = "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
(Reading database ... 21173 files and directories currently installed.)
Removing bind9 ...
* Stopping domain name service... bind9 [ OK ]
Processing triggers for man-db ...
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
How do I fix this error ?
JJD
8023 gold badges19 silver badges46 bronze badges
asked Jul 11, 2012 at 14:08
4
First run locale
to list what locales currently defined for the current user account:
$ locale
LANG=C
LANGUAGE=
LC_CTYPE=fi_FI.UTF-8
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE=fi_FI.UTF-8
LC_MONETARY="C"
LC_MESSAGES=fi_FI.UTF-8
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C"
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=
Then generate the missing locale and reconfigure locales to take notice:
$ sudo locale-gen "en_US.UTF-8"
Generating locales...
en_US.UTF-8... done
Generation complete.
$ sudo dpkg-reconfigure locales
Generating locales...
en_US.UTF-8... up-to-date
Generation complete.
Now you will not see any errors anymore!
Sheharyar
1,15812 silver badges18 bronze badges
answered Dec 10, 2012 at 12:45
Otto KekäläinenOtto Kekäläinen
5,9741 gold badge13 silver badges3 bronze badges
18
Nothing suggested above worked in my case (Ubuntu Server 12.04LTS). What finally helped
was putting to the file /etc/environment
:
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
For some reason it was missing. The outputs for locale and other commands appeared like the variables were properly defined. In other words don’t take for granted all the basic stuff is declared where it should be declared.
Nicolás
2593 silver badges11 bronze badges
answered Dec 16, 2012 at 4:11
MarcinMarcin
4,1591 gold badge12 silver badges3 bronze badges
16
They should disappear after issuing:
sudo locale-gen en_US en_US.UTF-8
sudo dpkg-reconfigure locales
dpkg-reconfigure
reconfigures packages after they have already been
installed. Pass it the names of a package or packages to reconfigure.
It will ask configuration questions, much like when the package was
first installed.
answered Jul 11, 2012 at 14:19
RinzwindRinzwind
288k39 gold badges561 silver badges701 bronze badges
11
Just add the following to your .bashrc
file (assuming you’re using bash)
export LC_ALL="en_US.UTF-8"
devav2
35.1k17 gold badges78 silver badges82 bronze badges
answered Nov 8, 2012 at 9:42
ratzratz
1,3891 gold badge8 silver badges2 bronze badges
8
This is a common problem if you are connecting remotely, so the solution is to not forward your locale. Edit /etc/ssh/ssh_config
and comment out SendEnv LANG LC_*
line.
warvariuc
2,2554 gold badges26 silver badges42 bronze badges
answered Oct 1, 2014 at 0:45
user249697user249697
1,1791 gold badge7 silver badges5 bronze badges
8
There is a command for that:
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
It updates /etc/default/locale
with provided values.
To apply the changes, you can
source /etc/default/locale
Katu
3,51324 silver badges41 bronze badges
answered Aug 1, 2014 at 11:51
sgtpepsgtpep
9976 silver badges3 bronze badges
5
What worked for me on 12.10 was this:
apt-get install language-pack-en-base
This was after dpkg-reconfigure locales
produced no results.
Seth
56.2k43 gold badges144 silver badges196 bronze badges
answered Apr 28, 2013 at 2:01
7
Don’t forget exit your SSH session (or your X11) by exiting and logging back in again. All of these suggestions didn’t work for me unless I logged back in….
answered Sep 26, 2014 at 6:51
1
For Ubuntu 12.10 none of the above worked except for ratzs’ solution. I recommend adding this to your /etc/bash.bashrc file:
export LC_ALL="en_ZA.UTF-8"
export LC_CTYPE="en_ZA.UTF-8"
answered Mar 27, 2013 at 3:19
1
I was stuck in a weird state where my local machine is set to es
and so the remote machine (via vagrant
) had been provisioned in an un-handled state. Therefore, I had to use the manual export=
only to facilitate a successful dpkg-reconfigure
. Then the system is fine.
export LC_ALL="en_US.UTF-8"
sudo dpkg-reconfigure locales
answered Mar 22, 2016 at 18:02
1
I wrote a bash script to fix above issue.The above answers are useful but setting the locale variables by simply exporting the values in shell variable will work only for a session. I permanently solved this issue by exporting the locale variables in .bash_profile file. You can also use /etc/profile
file instead of .bash_profile
.
echo "export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8">>~/.bash_profile
Don’t forget to source
the .bash_profile
and follow the script in easy setup.
answered Feb 27, 2016 at 19:26
Ajeet KhanAjeet Khan
4937 silver badges10 bronze badges
You can try:
export LANGUAGE=ru_RU.UTF-8
export LC_CTYPE=ru_RU.UTF-8
export LC_NUMERIC=ru_RU.UTF-8
export LC_TIME=ru_RU.UTF-8
export LC_COLLATE=ru_RU.UTF-8
export LC_MONETARY=ru_RU.UTF-8
export LC_MESSAGES=ru_RU.UTF-8
export LC_PAPER=ru_RU.UTF-8
export LC_NAME=ru_RU.UTF-8
export LC_ADDRESS=ru_RU.UTF-8
export LC_TELEPHONE=ru_RU.UTF-8
export LC_MEASUREMENT=ru_RU.UTF-8
export LC_IDENTIFICATION=ru_RU.UTF-8
export LC_ALL=ru_RU.UTF-8
where ru_RU
is your country code.
Eric Carvalho
53.1k102 gold badges134 silver badges161 bronze badges
answered Jun 17, 2013 at 13:34
KossKoss
1892 silver badges2 bronze badges
Current accepted answer is not sufficient in the troubleshoot strategy because you can have an human error.
You setup your system to en_US
but you have en_GB
enabled in/etc/locale.gen
like I had in the thread here for Raspberry Pi 3b.
You should have all your used locales enabled in /etc/locale.gen
.
I had en_GB.UTF-8 UTF-8
only enabled in /etc/locale.gen
. I should have there only enabled en_US.UTF-8 UTF-8
because of other commands run for it. So I commented GB and uncommented US, and everything work now
masi@raspberrypi:~ $ sudo vim /etc/locale.gen
masi@raspberrypi:~ $ sudo locale-gen
Generating locales (this might take a while)...
en_US.UTF-8... done
Generation complete.
masi@raspberrypi:~ $ sudo a2enmod rewrite && a2enmod headers && a2enmod ssl
Module rewrite already enabled
Module headers already enabled
Considering dependency setenvif for ssl:
Module setenvif already enabled
Considering dependency mime for ssl:
Module mime already enabled
Considering dependency socache_shmcb for ssl:
Module socache_shmcb already enabled
Module ssl already enabled
Now, I do not get those locale mistakes with any commands.
System: Raspbian Jessie
Hardware: Raspberry Pi 3b
answered Jun 22, 2016 at 20:25
As said here in the Debian Wiki, you can edit /etc/locale.gen
and add all locales (or uncomment them, I had a list of all locales but all except the one I used as comments) you wish to have support for on your system. Then, execute
sudo dpkg-reconfigure locales
to update the locales on your system. Now, all of the locales you added/uncommented in /etc/locale.gen
are available on your system without any warnings.
answered Dec 14, 2014 at 11:28
msrd0msrd0
2375 silver badges14 bronze badges
If you use KDE environment, check the setlocale.sh
file in ~/.kde/env/
:
$ cat ~/.kde/env/setlocale.sh
export LANG=en_US.UTF-8
export LANGUAGE=en_US:ru:en
answered Feb 5, 2014 at 8:36
2
This worked for me when I had the same problem (based on the solution provided by dman):
sudo sh -c "echo -e 'LC_ALL=en_US.UTF-8nLANG=en_US.UTF-8' >> /etc/environment"
answered Aug 27, 2014 at 5:21
2
-
You may need to run
sudo dpkg-reconfigure
also for the application you have installed while «locale» settings have been invalid / not matching.While system locale was incorrectly setup I installed
vim
. Later when system locale was fixed I saw a situation thatvim
was showing utf-8 characters incorrectly as strange symbols whilenano
andless
were showing them correctly. Runningsudo dpkg-reconfigure vim
appeared to fix the issue after the system settings were fixed.
-
I also noticed the same thing as already mentioned: You may need to disconnect/reconnect SSH to make changes visible.
msrd0
2375 silver badges14 bronze badges
answered Dec 18, 2014 at 19:02
ajaaskelajaaskel
931 silver badge5 bronze badges
Adding the following text to ~/.profile
works for me:
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
I am using Ubuntu 16.04 LTS 64-bit server on Linode.
answered May 9, 2017 at 3:07
Source of the problem
I experienced this, logging in from one machine to another via ssh
. The remote machine didn’t have the locale files, that I had on my local machine. You can either disable the forwarding of the locale from your local machine to the remote machine (in the file /etc/ssh/sshd_config
remove the line AcceptEnv LANG LC_CTYPE …
) or install the locale (changing it is not necessary in this case).
Installing
On Fedora, RHEL, Redhat, CentOS I used
sudo dnf install langpacks-de
for the german (de) language packs. Logged out and in and it worked.
Search for other langpacks with
dnf search langpacks-
Changing/Activating
To list available locales I used
localectl list-locales
And to set a new one
sudo localectl set-locale de_DE.utf8
answered Feb 6, 2020 at 23:43
erikerik
6578 silver badges15 bronze badges
4
remove locales using localepurge you don’t need and reboot
apt install localepurge
answered Apr 9, 2022 at 21:41
assayag.orgassayag.org
3762 silver badges7 bronze badges
In case you’re running Ubuntu 18.04 ( or earlier versions as well, such as 16.04, 14.04 ), you may be encountering a locales
warning or error while trying to update your package index or installing a package.
As the locales package configuration states:
Locales are a framework to switch between multiple languages and allow users to use their language, country, characters, collation order, etc.
The error looks something like this:
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_MONETARY = "de_DE.UTF-8",
LC_ADDRESS = "de_DE.UTF-8",
LC_TELEPHONE = "de_DE.UTF-8",
LC_NAME = "de_DE.UTF-8",
LC_MEASUREMENT = "de_DE.UTF-8",
LC_IDENTIFICATION = "de_DE.UTF-8",
LC_NUMERIC = "de_DE.UTF-8",
LC_PAPER = "de_DE.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_ALL to default locale: No such file or directory
You may encounter this error very often on a fresh install of Ubuntu or Debian.
One solution to fix this issue, first run the locale
command to list the locales currently defined for your user account.
$ locale
The output will look something like this:
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="de_DE.UTF-8"
LC_NUMERIC=de_DE.UTF-8
LC_TIME="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_MONETARY=de_DE.UTF-8
LC_MESSAGES="de_DE.UTF-8"
LC_PAPER=de_DE.UTF-8
LC_NAME=de_DE.UTF-8
LC_ADDRESS=de_DE.UTF-8
LC_TELEPHONE=de_DE.UTF-8
LC_MEASUREMENT=de_DE.UTF-8
LC_IDENTIFICATION=de_DE.UTF-8
LC_ALL=
To generate the missing locale and reconfigure locales, identify the name of your locale ( in my case de_DE.UTF-8
), or use one another one that you prefer, such as en_US.UTF-8
.
Then generate it using the following command:
$ sudo locale-gen "de_US.UTF-8"
And you’ll get the output:
Generating locales (this might take a while)...
de_DE.UTF-8... done
Generation complete.
After which, reconfigure locales using the following command:
$ sudo dpkg-reconfigure locales
And you’ll receive the output:
Generating locales...
de_DE.UTF-8... up-to-date
Generation complete.
And now you shouldn’t receive any more errors!
If you’ve encountered any issues with this short tutorial, please feel free to let us know in the comments or by contacting us via our social media channels, and we’ll get back to you as soon as possible.
Get a High RAM VPS at Entry-level Pricing
Starting with 2GB RAM at $6.99/month
Take your pick from our KVM VPS that offer a generous amount of RAM at an affordable price. We’ve got 5 plans for you to choose from, our smallest featuring 2GB RAM at $6.99/mo.
[Main Features]
— SSD Drives
— KVM Virtualization
— 1Gbps Shared Uplink
— Location: Chicago, IL
Pick one of our KVM plans
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.
If you aren’t using the default locale on your Debian based system, you’ll often run into errors when running things on the command line such as apt-get or Perl. Fixing this is luckily rather trivial.
First of all to verify you have a locale issue, look for warnings or even errors looking like this:
perl: warning: Setting locale failed or perl: warning: Falling back to the standard locale (“C”)
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = "en_US"
are supported and installed on your system.
.
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
To fix this issue, following questions need to be answered:
- Is locales installed?
- Which locales are necessary?
- Which locales are available?
- How to generate the necessary locales?
Is “locales” installed?
Run the following command:
sudo apt install locales
Either it will tell you locales is installed already, or it’ll install locales for you. Both are pretty good outcomes.
Which locales are necessary?
To see which locales are required on your system, run the following command:
sudo locale
You’ll want to look for any locales that are not en_US as this is usually default. For example if it mentions de_DE.UTF-8, take note of this.
Which locales are available?
Run the following command:
sudo locale -a | grep de_DE
Change the “de_DE” to whichever locale your system requires (see previous step). If you’re having a problem with this locale, chances are the output will be empty. To fix this, go to the next step.
How to generate the necessary locales?
This is dependent on your user, if you do not have root permissions (which is unlikely, as the previous steps required sudo) you’ll want to use locale-gen, if you do have root access use dpkg-reconfigure locales.
In case of dpkg-reconfigure, run:
sudo dpkg-reconfigure locales
Use the arrow keys to navigate this menu and spacebar to select the required locales. Don’t forget to set en_US.UTF-8 as your default on the next menu!
In case of locale-gen run:
locale-gen de_DE.UTF-8
At the end of this, simply log out and back in again, there should be no errors left on your console.
When I always try to install new package I get this message:
Can't set locale; make sure $LC_* and $LANG are correct!
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_GB:en",
LC_ALL = (unset),
LC_CTYPE = "en_GB.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_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
My OS is Debian Jessie 8.3 (Mate) using English with French keyboard.
When I type locale, I get this:
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
LANGUAGE=en_GB:en
LC_CTYPE=en_GB.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=
Jeff Schaller♦
65.2k34 gold badges106 silver badges241 bronze badges
asked Mar 11, 2016 at 13:27
Ismail SenseiIsmail Sensei
1,1391 gold badge9 silver badges13 bronze badges
Debian ships locales in source form. They need to be compiled explicitly. The reason for this is that compiled locales use a lot more disk space, but most people only use a few of them.
Run dpkg-reconfigure locales
as root, select the locales you want in the list (with your settings, you need en_GB
and en_US.UTF-8
— I recommend selecting en_US
and en_GB.UTF-8
as well) then press <OK>
.
Alternatively, edit /etc/locale.gen
, uncomment the lines for the locales you want, and run locale-gen
as root.
(Note: on Ubuntu, this works differently: run locale-gen
with the locales you want to generate as arguments, e.g. sudo locale-gen en_GB en_US en_GB.UTF-8 en_US.UTF-8
.)
Alternatively, Debian now has a package locales-all
which you can install instead of locales
. It has all the locales pre-generated. The downside is that they use up more disk space (112MB vs 16MB).
answered Mar 12, 2016 at 1:27
8
The top-rated solution didn’t help in my case, so I used this one:
export LC_ALL="en_US.UTF-8"
sudo dpkg-reconfigure locales
After that, I logged out and logged in and error was missing.
answered Mar 23, 2017 at 8:22
1
These commands saved my life
# 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
answered Mar 18, 2018 at 19:46
0
If you’re having this issue on a raspberry pi (or other?) and you’re getting the error when you ssh to the pi there are 2 other solutions
One is edit /etc/ssh/sshd_config
on the pi and comment out the line
AcceptEnv LANG LC_*
for example sudo nano /etc/ssh/sshd_config
After which you should restart the ssh server
sudo systemctl restart ssh
The other is on your client machine (not the pi) edit /etc/ssh/ssh_config
(different path from above) and comment out the line
SendEnv LANG LC_*
answered Aug 24, 2018 at 4:32
gmangman
2212 silver badges7 bronze badges
3
You need to install the package locales
(or locales-all
or the en_GB locale, depending on the Debian version you have).
A workaround not to have such errors: set LANG=C
to root, so that it will use no locales.
answered Mar 11, 2016 at 13:33