How to fix a locale setting warning from Perl - perl
When I run perl, I get the warning:
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
How do I fix it?
Here is how to solve it on Mac OS X v10.7 (Lion) or Cygwin (Windows 10):
Add the following lines to your bashrc or bash_profile file on the host machine:
# Setting for the new UTF-8 terminal support in Lion
export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
If you are using Z shell (zsh), edit file zshrc:
# Setting for the new UTF-8 terminal support in Lion
LC_CTYPE=en_US.UTF-8
LC_ALL=en_US.UTF-8
Your OS doesn't know about en_US.UTF-8.
You didn't mention a specific platform, but I can reproduce your problem:
% uname -a
OSF1 hunter2 V5.1 2650 alpha
% perl -e exit
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LC_ALL = (unset),
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
My guess is you used ssh to connect to this older host from a newer desktop machine. It's common for /etc/ssh/sshd_config to contain
AcceptEnv LANG LC_*
which allows clients to propagate the values of those environment variables into new sessions.
The warning gives you a hint about how to squelch it if you don't require the full-up locale:
% env LANG=C perl -e exit
%
or with Bash:
$ LANG=C perl -e exit
$
For a permanent fix, choose one of
On the older host, set the LANG environment variable in your shell's initialization file.
Modify your environment on the client side, e.g., rather than ssh hunter2, use the command LANG=C ssh hunter2.
If you have administrator rights, stop ssh from sending the environment variables by commenting out the SendEnv LANG LC_* line in the local /etc/ssh/ssh_config file. (Thanks to this answer. See Bug 1285 for OpenSSH for more.)
If you are creating a rootfs using debootstrap you will need to generate the locales. You can do this by running:
# (optional) enable missing locales
sudo nano /etc/locale.gen
# then regenerate
sudo locale-gen
This tip comes from, https://help.ubuntu.com/community/Xen
Use:
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8
It works for Debian. I don't know why - but locale-gen had not results.
Important! It's a temporary solution. It has to be run for each session.
This generally means you haven't properly set up locales on your Linux box.
On Debian or Ubuntu, that means you need to do
$ sudo locale-gen
$ sudo dpkg-reconfigure locales
See also man locale-gen.
For macOS & Mac OS X users only
I was getting the same warning while using Git
To resolve this warning Uncheck the Set locale environment variable on startup option and restart your terminal. Below screen shot represents my terminal settings.
It is simple fix in Ubuntu. You have to generate the Locales from scratch, running the following commands from the command line:
sudo locale-gen en_US en_US.UTF-8
sudo dpkg-reconfigure locales
This should create the locales and then re-configure them.
Adding the following to /etc/environment fixed the problem for me on Debian and Ubuntu (of course, modify to match the locale you want to use):
LANGUAGE=en_US.UTF-8
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
I am now using this:
$ cat /etc/environment
...
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
Then log out of SSH session and log in again.
Old answer:
Only this helped me:
$ locale
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE=en_US.UTF-8
LC_NUMERIC=ru_RU.UTF-8
LC_TIME=ru_RU.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=ru_RU.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=ru_RU.UTF-8
LC_NAME=ru_RU.UTF-8
LC_ADDRESS=ru_RU.UTF-8
LC_TELEPHONE=ru_RU.UTF-8
LC_MEASUREMENT=ru_RU.UTF-8
LC_IDENTIFICATION=ru_RU.UTF-8
LC_ALL=
$ sudo su
# export LANGUAGE=en_US.UTF-8
# export LANG=en_US.UTF-8
# export LC_ALL=en_US.UTF-8
# locale-gen en_US.UTF-8
Generating locales...
en_US.UTF-8... up-to-date
Generation complete.
# dpkg-reconfigure locales
Generating locales...
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_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... up-to-date
en_ZA.UTF-8... done
en_ZM.UTF-8... done
en_ZW.UTF-8... done
Generation complete.
# exit
$ locale
LANG=en_US.UTF-8
LANGUAGE=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=en_US.UTF-8
On Debian, after much searching, this did the trick.
First:
sudo apt-get purge locales
Then:
sudo aptitude install locales
And the famous:
sudo dpkg-reconfigure locales
This rids the system of locales, then re-installs locales and downgrades libc6 from 2.19 to 2.13 which is the issue. Then it configures locales again.
We will set locales that are not unset after reboot.
First open the Bash file and edit it:
nano .bashrc
Add these lines to the file:
export LC_ALL="en_US.UTF-8"
export LANG="en_US.UTF-8"
export LANGUAGE="en_US.UTF-8"
Activate the change by reloading Bash:
source ~/.bashrc
Test results:
locale
For Ubuntu use this,
#export LANGUAGE=en_US.UTF-8
#export LC_ALL=en_US.UTF-8
#export LANG=en_US.UTF-8
#export LC_TYPE=en_US.UTF-8
It worked for me.
If you use Mac OS X v10.10 (Yosemite) or above to connect in your server Linux, you can try these steps.
Keep your file /etc/ssh/sshd-config original
Put on your ~/.bash_profile
export LANG="en_US"
export LC_ALL=$LANG.UTF-8
Run
dpkg-reconfigure locales
And select "en_US.UTF-8"
For Debian users, I have this problem after modifying my locale to change machine's language. This is what I did:
Modify .bashrc:
export LANG=fr_FR.UTF-8
export LC_ALL=fr_FR.UTF-8
Uncomment line fr_FR.UTF-8 in file etc/locale.gen -> sudo locale-gen to generate the missing package
sudo update-locale
sudo dpkg-reconfigure locales to configure my locale to fr_FR.UTF-8
Add extra lines to the etc/default/locale file:
LANGUAGE=en_US.UTF-8
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
LC_TYPE=en_US.UTF-8
Reboot my computer and everything works fine
sudo nano /etc/locale.gen
Uncomment the locales you want to use (e.g. en_US.UTF-8 UTF-8):
Then run:
sudo /usr/sbin/locale-gen
Source: Configuring Locales
You need to configure locale appropriately in /etc/default/locale, logout, login, and then run the regular commands
root#host:~# echo -e 'LANG=en_US.UTF-8\nLC_ALL=en_US.UTF-8' > /etc/default/locale
root#host:~# exit
local-user#local:~$ ssh root#host
root#host:~# locale-gen en_US.UTF-8
root#host:~# dpkg-reconfigure locales
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_ALL to default locale: No such file or directory
Solution:
Try this (uk_UA.UTF-8 is my current locale. Write your locale, for example en_US.UTF-8 !)
sudo locale-gen uk_UA.UTF-8
and this.
sudo dpkg-reconfigure locales
For Ubuntu Server and Debian:
No need to create exports in bashrc or dealing with dpkg-reconfigure.
Just replace the contents of /etc/default/locale with:
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
For anyone connecting to DigitalOcean or some other Cloud hosting provider from the iTerm2.app on macOS v10.13 (High Sierra) and getting this error on some commands:
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.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
This fixed the problem for me:
For me, I fixed this error by editing the .bashrc file, adding exports. Add after the initial comments.
Add language support.
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_TYPE=en_US.UTF-8
Debian GNU/Linux 11 (bullseye)
I encountered this issue after creating a brand new VM instance in GCP.
Basically, I have just run the following
$ sudo apt-get update
$ sudo apt-get upgrade
Here I have got the error
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LC_TERMINAL = "iTerm2",
LANG = "C"
are supported and installed on your system.
Here is how I fixed it.
Install the locales first.
$ sudo apt-get install locales
Open the locale file (use your favorite editor).
$ sudo nano /etc/default/locale
Add the following and save it.
LANGUAGE=en_US.UTF-8
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
Run the following.
$ sudo localedef -i en_US -f UTF-8 en_US.UTF-8
Restart your terminal.
Run the command to test and close it via ctrl + d.
$ perl
Note:
I created an instance to just test my solution in order to ensure. Please let me know if it doesn't work for you.
I hope it helps you.
Adding the correct locale to ~/.bashrc, ~/.bash_profile, /etc/environment and the like will solve the problem, however it is not recommended, as it overrides the settings from /etc/default/locale, which is confusing at best and may lead to the locales not being applied consistently at worst.
Instead, one should edit /etc/default/locale directly, which may look something like this:
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE=en_US
The change will take effect the next time you log in. You can get the new locale in an existing shell by sourcing /etc/default/locale like this:
$ . /etc/default/locale
Add missing locales to file .bash_profile:
echo "export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8">>~/.bash_profile
Then source your .bash_profile file:
source ~/.bash_profile
Following the accepted answer:
LANG=C ssh hunter2.
LC_ALL=C ssh hunter2
on the client side did the trick for me.
With zsh ohmyzsh I added this to the .zshrc:
# You may need to manually set your language environment
LANGUAGE=en_US.UTF-8
LANG=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LC_ALL=en_US.UTF-8
By removing the line export LANG=en_US.UTF-8
Reopened a new tab and SSHed in, worked for me :)
In my case, this was the output:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_PAPER = "ro_RO.UTF-8",
LC_ADDRESS = "ro_RO.UTF-8",
....
The solution was:
sudo locale-gen ro_RO.UTF-8
Add LC_ALL="en_GB.utf8" to /etc/environment and reboot. That's all.
If you don't care about the locale issue, you can set PERL_BADLANG=0. Of course, this could result in incorrect localisation.
Another Git-related answer:
The source of the problem might be the Git server. If all else fails, try doing dpkg-reconfigure locales (or whatever is appropriate for your distribution) on the server.
Export the variable
$ export LANGUAGE=en_US.UTF-8
$ export LC_ALL=en_US.UTF-8
$ export LANG=en_US.UTF-8
$ export LC_CTYPE=en_US.UTF-8
Next run
$ sudo locale-gen
$ sudo dpkg-reconfigure locales
When you run dpkg-reconfigure locales it asks you to choose the locales, choose en_US.UTF-8 . If you run this by selecting all locales, it will take some time to configure.
Related
Perl: Setting locale failed in conda environment [duplicate]
When I run perl, I get the warning: perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LANG = "en_US.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C"). How do I fix it?
Here is how to solve it on Mac OS X v10.7 (Lion) or Cygwin (Windows 10): Add the following lines to your bashrc or bash_profile file on the host machine: # Setting for the new UTF-8 terminal support in Lion export LC_CTYPE=en_US.UTF-8 export LC_ALL=en_US.UTF-8 If you are using Z shell (zsh), edit file zshrc: # Setting for the new UTF-8 terminal support in Lion LC_CTYPE=en_US.UTF-8 LC_ALL=en_US.UTF-8
Your OS doesn't know about en_US.UTF-8. You didn't mention a specific platform, but I can reproduce your problem: % uname -a OSF1 hunter2 V5.1 2650 alpha % perl -e exit perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LC_ALL = (unset), LANG = "en_US.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C"). My guess is you used ssh to connect to this older host from a newer desktop machine. It's common for /etc/ssh/sshd_config to contain AcceptEnv LANG LC_* which allows clients to propagate the values of those environment variables into new sessions. The warning gives you a hint about how to squelch it if you don't require the full-up locale: % env LANG=C perl -e exit % or with Bash: $ LANG=C perl -e exit $ For a permanent fix, choose one of On the older host, set the LANG environment variable in your shell's initialization file. Modify your environment on the client side, e.g., rather than ssh hunter2, use the command LANG=C ssh hunter2. If you have administrator rights, stop ssh from sending the environment variables by commenting out the SendEnv LANG LC_* line in the local /etc/ssh/ssh_config file. (Thanks to this answer. See Bug 1285 for OpenSSH for more.)
If you are creating a rootfs using debootstrap you will need to generate the locales. You can do this by running: # (optional) enable missing locales sudo nano /etc/locale.gen # then regenerate sudo locale-gen This tip comes from, https://help.ubuntu.com/community/Xen
Use: export LANGUAGE=en_US.UTF-8 export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 export LC_CTYPE=en_US.UTF-8 It works for Debian. I don't know why - but locale-gen had not results. Important! It's a temporary solution. It has to be run for each session.
This generally means you haven't properly set up locales on your Linux box. On Debian or Ubuntu, that means you need to do $ sudo locale-gen $ sudo dpkg-reconfigure locales See also man locale-gen.
For macOS & Mac OS X users only I was getting the same warning while using Git To resolve this warning Uncheck the Set locale environment variable on startup option and restart your terminal. Below screen shot represents my terminal settings.
It is simple fix in Ubuntu. You have to generate the Locales from scratch, running the following commands from the command line: sudo locale-gen en_US en_US.UTF-8 sudo dpkg-reconfigure locales This should create the locales and then re-configure them.
Adding the following to /etc/environment fixed the problem for me on Debian and Ubuntu (of course, modify to match the locale you want to use): LANGUAGE=en_US.UTF-8 LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8
I am now using this: $ cat /etc/environment ... LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 Then log out of SSH session and log in again. Old answer: Only this helped me: $ locale locale: Cannot set LC_ALL to default locale: No such file or directory LANG=en_US.UTF-8 LANGUAGE= LC_CTYPE=en_US.UTF-8 LC_NUMERIC=ru_RU.UTF-8 LC_TIME=ru_RU.UTF-8 LC_COLLATE="en_US.UTF-8" LC_MONETARY=ru_RU.UTF-8 LC_MESSAGES="en_US.UTF-8" LC_PAPER=ru_RU.UTF-8 LC_NAME=ru_RU.UTF-8 LC_ADDRESS=ru_RU.UTF-8 LC_TELEPHONE=ru_RU.UTF-8 LC_MEASUREMENT=ru_RU.UTF-8 LC_IDENTIFICATION=ru_RU.UTF-8 LC_ALL= $ sudo su # export LANGUAGE=en_US.UTF-8 # export LANG=en_US.UTF-8 # export LC_ALL=en_US.UTF-8 # locale-gen en_US.UTF-8 Generating locales... en_US.UTF-8... up-to-date Generation complete. # dpkg-reconfigure locales Generating locales... 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_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... up-to-date en_ZA.UTF-8... done en_ZM.UTF-8... done en_ZW.UTF-8... done Generation complete. # exit $ locale LANG=en_US.UTF-8 LANGUAGE=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=en_US.UTF-8
On Debian, after much searching, this did the trick. First: sudo apt-get purge locales Then: sudo aptitude install locales And the famous: sudo dpkg-reconfigure locales This rids the system of locales, then re-installs locales and downgrades libc6 from 2.19 to 2.13 which is the issue. Then it configures locales again.
We will set locales that are not unset after reboot. First open the Bash file and edit it: nano .bashrc Add these lines to the file: export LC_ALL="en_US.UTF-8" export LANG="en_US.UTF-8" export LANGUAGE="en_US.UTF-8" Activate the change by reloading Bash: source ~/.bashrc Test results: locale
For Ubuntu use this, #export LANGUAGE=en_US.UTF-8 #export LC_ALL=en_US.UTF-8 #export LANG=en_US.UTF-8 #export LC_TYPE=en_US.UTF-8 It worked for me.
If you use Mac OS X v10.10 (Yosemite) or above to connect in your server Linux, you can try these steps. Keep your file /etc/ssh/sshd-config original Put on your ~/.bash_profile export LANG="en_US" export LC_ALL=$LANG.UTF-8 Run dpkg-reconfigure locales And select "en_US.UTF-8"
For Debian users, I have this problem after modifying my locale to change machine's language. This is what I did: Modify .bashrc: export LANG=fr_FR.UTF-8 export LC_ALL=fr_FR.UTF-8 Uncomment line fr_FR.UTF-8 in file etc/locale.gen -> sudo locale-gen to generate the missing package sudo update-locale sudo dpkg-reconfigure locales to configure my locale to fr_FR.UTF-8 Add extra lines to the etc/default/locale file: LANGUAGE=en_US.UTF-8 LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 LC_TYPE=en_US.UTF-8 Reboot my computer and everything works fine
sudo nano /etc/locale.gen Uncomment the locales you want to use (e.g. en_US.UTF-8 UTF-8): Then run: sudo /usr/sbin/locale-gen Source: Configuring Locales
You need to configure locale appropriately in /etc/default/locale, logout, login, and then run the regular commands root#host:~# echo -e 'LANG=en_US.UTF-8\nLC_ALL=en_US.UTF-8' > /etc/default/locale root#host:~# exit local-user#local:~$ ssh root#host root#host:~# locale-gen en_US.UTF-8 root#host:~# dpkg-reconfigure locales
perl: warning: Falling back to the standard locale ("C"). locale: Cannot set LC_ALL to default locale: No such file or directory Solution: Try this (uk_UA.UTF-8 is my current locale. Write your locale, for example en_US.UTF-8 !) sudo locale-gen uk_UA.UTF-8 and this. sudo dpkg-reconfigure locales
For Ubuntu Server and Debian: No need to create exports in bashrc or dealing with dpkg-reconfigure. Just replace the contents of /etc/default/locale with: LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
For anyone connecting to DigitalOcean or some other Cloud hosting provider from the iTerm2.app on macOS v10.13 (High Sierra) and getting this error on some commands: 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.UTF-8" are supported and installed on your system. perl: warning: Falling back to a fallback locale ("en_US.UTF-8"). This fixed the problem for me:
For me, I fixed this error by editing the .bashrc file, adding exports. Add after the initial comments. Add language support. export LANGUAGE=en_US.UTF-8 export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 export LC_TYPE=en_US.UTF-8
Debian GNU/Linux 11 (bullseye) I encountered this issue after creating a brand new VM instance in GCP. Basically, I have just run the following $ sudo apt-get update $ sudo apt-get upgrade Here I have got the error perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LC_CTYPE = "UTF-8", LC_TERMINAL = "iTerm2", LANG = "C" are supported and installed on your system. Here is how I fixed it. Install the locales first. $ sudo apt-get install locales Open the locale file (use your favorite editor). $ sudo nano /etc/default/locale Add the following and save it. LANGUAGE=en_US.UTF-8 LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 Run the following. $ sudo localedef -i en_US -f UTF-8 en_US.UTF-8 Restart your terminal. Run the command to test and close it via ctrl + d. $ perl Note: I created an instance to just test my solution in order to ensure. Please let me know if it doesn't work for you. I hope it helps you.
Adding the correct locale to ~/.bashrc, ~/.bash_profile, /etc/environment and the like will solve the problem, however it is not recommended, as it overrides the settings from /etc/default/locale, which is confusing at best and may lead to the locales not being applied consistently at worst. Instead, one should edit /etc/default/locale directly, which may look something like this: LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_CTYPE=en_US The change will take effect the next time you log in. You can get the new locale in an existing shell by sourcing /etc/default/locale like this: $ . /etc/default/locale
Add missing locales to file .bash_profile: echo "export LANGUAGE=en_US.UTF-8 export LANG=en_US.UTF-8 export LC_ALL=en_US.UTF-8">>~/.bash_profile Then source your .bash_profile file: source ~/.bash_profile
Following the accepted answer: LANG=C ssh hunter2. LC_ALL=C ssh hunter2 on the client side did the trick for me.
With zsh ohmyzsh I added this to the .zshrc: # You may need to manually set your language environment LANGUAGE=en_US.UTF-8 LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 LC_ALL=en_US.UTF-8 By removing the line export LANG=en_US.UTF-8 Reopened a new tab and SSHed in, worked for me :)
In my case, this was the output: LANGUAGE = (unset), LC_ALL = (unset), LC_PAPER = "ro_RO.UTF-8", LC_ADDRESS = "ro_RO.UTF-8", .... The solution was: sudo locale-gen ro_RO.UTF-8
Add LC_ALL="en_GB.utf8" to /etc/environment and reboot. That's all.
If you don't care about the locale issue, you can set PERL_BADLANG=0. Of course, this could result in incorrect localisation.
Another Git-related answer: The source of the problem might be the Git server. If all else fails, try doing dpkg-reconfigure locales (or whatever is appropriate for your distribution) on the server.
Export the variable $ export LANGUAGE=en_US.UTF-8 $ export LC_ALL=en_US.UTF-8 $ export LANG=en_US.UTF-8 $ export LC_CTYPE=en_US.UTF-8 Next run $ sudo locale-gen $ sudo dpkg-reconfigure locales When you run dpkg-reconfigure locales it asks you to choose the locales, choose en_US.UTF-8 . If you run this by selecting all locales, it will take some time to configure.
pg_restore could not execute query: ERROR: invalid locale name: "en_US.UTF-8"
I use pg_restore on Windows 10 with a dump file made on Linux. I search on the web but I don't find answer. [NEW] : I install Ubuntu on my computer to use pg_restore but when I send pg_restore -d mydatabase /home/user/Documents/dumpfile.dump the command line is blocked. Someone has this issue ?
Your new ubuntu installation hasn't defined the en_US.UTF-8 locale yet. So, when you're trying to restore the dumpfile, the dumpfile attempts to do something like: CREATE DATABASE <database> WITH TEMPLATE = ... LC_COLLATE = 'en_US.UTF-8'... But, 'en_US.UTF-8' is not defined by your new ubuntu server. First, you can verify this: # list all "known" locales. In my case, on new Ubuntu 20, I get: $ locale -a C C.UTF-8 POSIX Edit existing /etc/locale.gen file, which contains the list of possible locales. Most locales will be commented out. These will not be defined, so, un-comment the line with 'en_US.UTF-8'. Run (as root) locale-gen. root# locale-gen Generating locales (this might take a while)... en_US.UTF-8... done Generation complete. Notice it's now a configured locale: $ locale -a C C.UTF-8 POSIX en_US.utf8 (Yes, it is lower case utf8, not a problem) Restart your postgres server (so it sees the new locale -- you do not need to restart the ubuntu server itself), and you restore show now work.
You will need to do some research on locales. The place to start is the documentation. Postgres relies on the operating system for locale information. The names differ between Posix and Windows. Presumably, the simplest solution is to change the name somehow. There might be a way to get Windows to understand the Posix names.
Set locale to sv_SE on debian
Using Postgres 9.1 on Debian 7 Postgresql gives an error message when creating database setting "LC_COLLATE = 'sv_SE.UTF-8'" As I understand now, the language support is from the underlying Debian and i cannot set the correct language there. > locale LANG= LANGUAGE= LC_CTYPE="POSIX" LC_NUMERIC="POSIX" LC_TIME="POSIX" LC_COLLATE="POSIX" LC_MONETARY="POSIX" LC_MESSAGES="POSIX" LC_PAPER="POSIX" LC_NAME="POSIX" LC_ADDRESS="POSIX" LC_TELEPHONE="POSIX" LC_MEASUREMENT="POSIX" LC_IDENTIFICATION="POSIX" LC_ALL= and this does not help: > locale-gen sv_SE.UTF-8 Generating locales (this might take a while)... Generation complete. Resulting in: > locale -a C C.UTF-8 POSIX Any clue what to do? The aim is to get Postgresql correct sort order when creating database. I found the solution by chance: Uncomment the # sv_SE.UTF-8 in etc/locale.gen by deleting # Run sudo locale-gen Restart server
locale-gen on Debian doesn't expect any argument, so presumably the sv_SE.UTF-8 passed to it is ignored. From its manpage: SYNOPSIS locale-gen .... locale-gen is a program that reads the file /etc/locale.gen and invokes localedef for the chosen localisation profiles. Run locale-gen after you have modified the /etc/locale.gen file. This differs from Ubuntu (manpage) which for some reason has a very different synopsis and behavior: locale-gen [options] [locale] [language] ... The problem in the question stems from applying to Debian a method to generate locales that works only with Ubuntu. The step #3 in your edit may also be emphasized: the postgres server must be restarted for it to recognize a new locale, otherwise it will complain it doesn't exist.
MongoDB mongorestore failure: locale::facet::_S_create_c_locale name not valid
I created a dump with mongodump on computer A (ubuntu 12.04 server). I moved it to computer B (ubuntu 12.04 server) and typed: mongorestore -db db_name --drop db_dump_path It failed and it reported: connected to: 127.0.0.1 terminate called after throwing an instance of 'std::runtime_error' what(): locale::facet::_S_create_c_locale name not valid Aborted I've successfully accomplished this operation before and this strange behavior has never occurred. What do I need to do to fix this?
On my distro "locale-gen" was not installed and it turned out all I had to do is set the LC_ALL environment variable. so the following command fixed it: export LC_ALL="en_US.UTF-8" hopefully it will help someone else...
Actually it isn't strictly related to MongoDB. Somehow the language on computer B was not defined correctly. I managed to fix it by typing: sudo locale-gen en_US en_US.UTF-8 sudo locale-gen it_IT it_IT.UTF-8 sudo locale-gen xx_xx xx_XX.UTF-8 ... sudo dpkg-reconfigure locales These commands will generate and configure the needed locales. After those steps mongorestore got back working as usual.
Exporting LC_ALL="en_US.UTF-8" only works if you have the en_US locale installed. If you want to avoid installing the locales package (or its equivalent on distributions other than Debian derivatives), then you can instead use: export LC_ALL=C.UTF-8 which will not require any extra locale data.
If you are using a Mac OSX and SSH this might be issued by wrong LC_CTYPE. $ locale 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 LANGUAGE= 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= Unset the wrong var. $ unset LC_CTYPE Check whether locale is working fine. $ locale LANG=en_US.UTF-8 LANGUAGE= 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= Now mongo also should do fine.
To make the fix permanent you can edit one of those files: sudo vim /etc/default/locale sudo vim /etc/environment And add the line LC_ALL="en_US.UTF-8"
Got same problem on debian 7 without locale-gen (command not found) installed. I solved this way: su apt-get install locales dpkg-reconfigure locales # select locales you want! Now mongodb should start. Source
Postgres locale error
I have a Postgres database hosted on Digital River, on Ubuntu, and followed these instructions to install: But something is wrong with the locale settings and I cannot work out how to fix it. When I run the psql command I get the following error: postgres#assay:/home/deployer$ psql perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = "en_US:en", LC_ALL = (unset), LC_CTYPE = "UTF-8", LANG = "en_US.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C"). psql (9.1.9)
Thank you very much to Kamal Nasser on the Digital River forums for providing the correct answer (the following commands below requires root privileges): $ locale-gen en_US en_US.UTF-8 $ dpkg-reconfigure locales I think this is the correct link to the original answer: the Digital Ocean site is not responding so I can't check it. https://www.digitalocean.com/community/questions/postgresql-and-rails-4
After trying ardochhigh's answer: $ sudo locale-gen en_US en_US.UTF-8 $ sudo dpkg-reconfigure locales the problem persisted After that I saw this answer that solved the problem for me: https://www.digitalocean.com/community/questions/language-problem-on-ubuntu-14-04 Aparently LAGUAGE shell variable is not set: $ sudo bash $ export LANGUAGE="en_US.UTF-8" $ echo 'LANGUAGE="en_US.UTF-8"' >> /etc/default/locale $ echo 'LC_ALL="en_US.UTF-8"' >> /etc/default/locale $ # next: logout and login