Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This self-answered question solves the following issues:

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

and some other locale related problems.

EDIT: Restricting this to my own answer only seems, in retrospect, rather inefficient. Please feel free to add your 2cents. Or as many as you can spare....

share|improve this question
add comment

3 Answers

up vote 8 down vote accepted

We are working completely in the shell (bash).

The first thing everyone should do is

sudo dpkg-reconfigure locales

The output may be the errors mentioned above and a list of locales that the script generates. Note that the locales generated there are the only ones valid for your system. As you can see the language settings are just a bunch of environment variables. You can, just for fun, try a different language bash like this:

LANG=es_NI.UTF-8 bash
ls somedirectorynamethatdoesnotexistonyoursystem

Tu hablas espaniol? :-) (if the es_NI.UTF-8 was not in your list of locales just choose another)

Ok. Obviously the LANG environment variable helps with the rest of the settings, because, in our spanish bash we can now do

dpkg-reconfigure locales

or whatever command whose error messages led you here, and there should be no errors. If there are, then there's something more sinister wrong that will not be covered by this post.

So, where do we set this variable LANG? A quick search through the /etc/ directory (with rgrep LANG /etc/*) leads us to the file /etc/default/locale. There you can set the value of the variable to something different/correct. For example

LANG=en_US.UTF-8

(That one should always work) To finish this: The variables mentioned in the error messages, all "derive" from LANG, meaning that they default to whatever LANG is set to, but you can set them to your liking if you want your shell to speak a different language. The package language-env helps with this.

sudo apt-get install language-env
set-language-env

The script is meant to automatically creates entries for your .bashrc etc.

I haven't tried it myself.

I hope this helps someone.

Btw:

  1. you can find the generated locales under ls usr/share/locale
share|improve this answer
add comment

Short answer:

Run dpkg-reconfigure locales as root.

(While in the dialog press Enter until you find your language, see its number, press Enter again, until you are asked for the number. Enter the number of you language, Enter, done. If you don't know better, take the UTF8-Version of you language)

Resources: https://wiki.debian.org/Locale

share|improve this answer
add comment

I have tried many many solutions and none of them worked for me on Debian 7.

So, I added export LC_ALL=en_US.UTF-8 to the end of /etc/profile and the warnings have gone.

share|improve this answer
    
You should edit /etc/default/locale instead. –  n.st Sep 21 '13 at 20:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.