50

I didn't get an answer but I wasn't doing anything and this is an interesting topic. In Ubuntu 12.04, when opening a file in gedit or if I am working on the command line in dpkg, I get returned the error "locale not supported, falling back to default "C" libraries", and the one below,

Gtk-WARNING **: Locale not supported by C library.
    Using the fallback 'C' locale.
  • Your locales appear to be broken. How did you install Ubuntu exactly? It seems like you installed it in a way that locales aren't configured properly. Please provide some more information regarding that in your question (edit it). And no, the C locale is where it falls back to if no localisation is available. It's from the C programming language. – gertvdijk Oct 16 '13 at 08:55
  • thanks for the reply. My Ubuntu install is a folder inside of the Windows directory. I know why I installed it there. I was lazy at install and allowed the Linux demon do that part for me. – Diogenes Lantern Oct 16 '13 at 09:03

8 Answers8

49

First make sure your library language is installed

sudo apt-get install language-pack-en-base,

for example.

Then, as superuser, shorten the work by allowing Ubuntu to automatically configure them:

sudo dpkg-reconfigure locales

Check your setup, if it's correct then good. But if you have the LANG= or LANGUAGE= settings blank, run this in command line:

locale -a

Which generates the locales installed and available to you.

Choose the locale from the output generated that fits your situation, and export that setting to replace your locales, for example:

export LC_ALL="en.utf-8"

For manual installation use export to set locale by hand which will manually install custom locales, first run the set up as above.

Then, say you want to install "en_us-8" for language but have need for another locale for NUMERIC and TIME, you may wish to use "en_NZ.utf-8" (remember: these are case-sensitive) or LANGUAGE="en_GB.utf-8" and NUMERIC="en.dk.ISO-8859-15". Traveling to New Zealand, I could change the locale LANGUAGE="en.NZ". For Germany, I would just need to install the locales pkg for it and input, in terminal, like the examples below:

export LC_ALL="en_US"
export LANG="en_US"
export LANGUAGE="en_NZ"
export C_CTYPE="en_US"
export LC_NUMERIC=
export LC_TIME=en"en_US"

LC_ALL= may remain empty.

Yusuf K.
  • 103
5

This occurred to me more than once, on my mint mate 18, which is based on Ubuntu 16.04, so I'd like to share the solution I found, in case anyone needs.

Steps:

(These steps works for mint mate, but Ubuntu might have similar configurations, not sure)

  • Open "language settings".
  • Install languages, if missing. (For me, I would install Chinese & Japanese languages in addition to English)
  • For option Language and Region, make sure the default language for them are proper, e.g set to "English, United States UTF-8",
  • Reboot, if any change is made.
  • Check whether it's fine.
muru
  • 197,895
  • 55
  • 485
  • 740
Eric
  • 492
3

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 configures locales again.

tkjef
  • 101
  • 2
    This is very very misleading. Never use this answer, the first command will drop a lot software together with their data, e.g postgresql. – Eric Dec 24 '16 at 07:45
  • @EricWang you are correct that it may drop other software, and that will happen because that software is relying on the libc6 2.19 library (or something higher). Very often that software was the thing that upgraded your system and put it in this state of locales not being supported by the C library. Regardless, you should review what is being removed before confirming. – tkjef Dec 31 '16 at 21:29
1
$ mkdir -p $HOME/.locale
$ I18NPATH=./wrk/ localedef -f UTF-8 -i fi_SE $HOME/.locale/fi_SE.UTF-8
$ LOCPATH=$HOME/.locale LC_ALL=fi_SE.UTF-8 date
$ echo "export LOCPATH=\$HOME/.locale" >> $HOME/.bashrc
$ echo "export LANG=fi_SE.UTF-8" >> $HOME/.bashrc

fi_SE to your LOCALE, and see UTF-8 or utf8

  • solved using: mkdir -p $HOME/.locale and I18NPATH=./wrk/ localedef -f UTF-8 -i en_GB $HOME/.locale/en.utf-8 and LOCPATH=$HOME/.locale LC_ALL=en.utf-8 date and
    "export LOCPATH=\$HOME/.locale" >> $HOME/.bashrc and "export LANG=en.utf-8" >> $HOME/.bashrc and
    source ~/.bashrc
    – Estatistics Jul 30 '22 at 08:36
0

it just worked right for me by going to gnome-terminal and typing the command apt --fix locales and reboot your linux and your wait for the terminal error is over.it would be on your monitor this time for sure.

0

I managed to cause this myself when migrating home directory dot files to a new machine, and I failed to identify the cause for a while on account of searching files for LC_ but not LOC.

The ~/.bashrc file I copied had the following:

export LOCPATH=/var/guix/profiles/per-user/root/guix-profile/lib/locale

(the particular value here was on account of prior experiments with GNU Guix on the old machine; but the relevant fact is simply that the environment variable was set to a now-invalid path.)

This resulted in the following error when running various programs:

Warning: locale not supported by C library, locale unchanged

And these errors when running 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

Removing (or commenting out) the LOCPATH line resolved my issues.

phils
  • 101
  • 2
0

In my case,

sudo apt-get install language-pack-en-base
sudo dpkg-reconfigure locales

LANGUAGE=en_US:en psppire

0

With locales you must remove the language that conflicts with your system, this worked for me, on ubunty kylin 16.04, I have installed it over ubuntu 14.04

Bart
  • 1