PDA

View Full Version : [ubuntu] 6.06 to 8.04 Upgrade Causes Locale Error (w/ solution)



Kadin2048
December 2nd, 2008, 07:47 PM
I spent the good portion of a day figuring this little annoyance out, and since I didn't find a solution elsewhere in the forms (and all the other threads about it are currently closed), I thought I'd post both my problem and the solution I found here, in the hopes it might help someone else out down the road.

I upgraded from 6.06 LTS to 8.04 LTS, and after rebooting started getting the "can't set locale" error on lots of commands.

For example:

$ man
man: can't set the locale; make sure $LC_* and $LANG are correct
What manual page do you want?

I also started getting lots of email from cron, telling me that all my cron tasks were getting the same error. (In some cases I have cron tasks running every few minutes so there were a lot of messages.)

I tried many of the solutions suggested elsewhere, including running dpkg-reconfigure locale and other stuff.

What I discovered was that my LANG variable was set incorrectly. To check this, I looked at the output of echo $LANG and saw that I was getting en_US when what I should have been getting was en_US.UTF-8.

Basically, the solution was to edit /etc/environment (not .bashrc or .bash_profile; they would not have solved the issue of getting the error from cron jobs), removing the existing LANG entry and adding:


LANG="en_US.UTF-8"
LANGUAGE="en_US.UTF-8"
LC_ALL="en_US.UTF-8"

This seemed to take care of the problem. Apparently the entry for LANG that was in there, which was LANG="en_US", was correct in 6.06 but wrong in 8.04, and wasn't updated by the installation scripts.

Hope this helps someone.

ferral-cat
May 14th, 2009, 08:34 PM
Thanks kadin,

I had the same error after I went into Synaptic and removed ALL language packs. Now I was able to get the error fixed but I took many steps:

1)
sudo kwrite /etc/environment

Made mine look like this:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
LANG="en_US.UTF-8"
LANGUAGE="en_US.UTF-8"
LC_ALL="en_US.UTF-8"

2)
sudo dpkg-reconfigure locales


3)
echo $LANG

4)
export LANG=en_US.UTF-8

Now the error is gone and I am not sure which of those steps was the one that actually fixed it but give that a try prior to reinstalling the whole O/S

About me:

Running Linux Mint 8.10 (Intrepid) KDE version
with Kernel 2.6.27-7-generic
Live in United States, EST - Speak English