How to fix locales on Debian Wheezy after broken update from jessie repository

Aleksander A asked:

I tried to install nodejs and npm packages on my VDS with Debian Wheezy.
But not to compile source and by the laziness, I found instruction in the Internet to include jessie sources and install from it.

The installation didn’t complete and I even didn’t get nodejs and npm in my system.
But now I have this problem in my locale settings:

# 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

I deleted jessie souce from sourses list. Then update and upgrade system.
When I try to reinstall locales, I get this error, so some tailes from jessie still exists:

# apt-get install --reinstall locales
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 locales : Depends: glibc-2.13-1
           Depends: debconf (>= 0.5) but it is not going to be installed or
E: Unable to correct problems, you have held broken packages.

Could you help me? What can I do?
Now this error appearse where often, especially during installation new packages.
I don’t know if it affect on other tasks, but I didn’t feel the influence still.


My answer:

Whenever someone tells you to add sources from unstable or testing onto your stable system, you should ignore them and keep looking for another option. This is the #1 most common way Debian systems get broken.

To fix your system, change all your sources back to wheezy, then run:

apt-get update
apt-get dist-upgrade

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.