Why is "LANG=C;sudo apt-get clean" etc recommended?

I came across this wiki page: Package Manager Troubleshooting Procedure.

In it, there were commands such as:

LANG=C;sudo apt-get clean
LANG=C;sudo apt-get autoclean
LANG=C;sudo apt-get -f install
LANG=C;sudo apt-get --fix-missing install
LANG=C;sudo apt-get --purge autoremove
LANG=C;sudo apt-get --fix-missing update -o APT::Cache-Limit=100000000
LANG=C;sudo apt-get update -o APT::Cache-Limit=100000000 && sudo apt-get dist-upgrade

So what is the purpose of LANG=C;?


Solution 1:

If you're troubleshooting, you'll likely post your results in some forum, or here, sooner or later.

When that happens, it's much more simpler for other users to understand your logs and output, if they're not internationalised.

That's to say, if you're using French or Chinese or Hindi or whatever as your system language, the output is likely to use terms in that language, and that makes it all the more harder to understand what's going on.

The C locale forces default output (which is typically ASCII-only English).

It's best to start a troubleshooting session with:

export LC_ALL=C

Instead of setting specific locale variables, or setting it just for a specific command.

Solution 2:

LANG=C will make your terminal output fall-back to the default locale. As this guide suggests you sending your output to Launchpad for support, they are having you do this so that, when you paste it in, others will be able to read it no matter what language you usually use.

Solution 3:

A small addition although it probably doesn't apply in the case of apt as I regard it as a quite stable piece of software:

Some programs notoriosly misbehave when using a different setting for LANG (or atleast different from C or en_US).

Unity had (still has?) these issues (and Unity-based games), Unreal Engine had some problems too. Also some of the build-scripts for Android only ran with LANG=C properly or compiled only with this environment variable set this way.

So this could also help troubleshooting as the bug might not even occur with this setting.