Man Command Locale Error – How to Fix

localeman

I have

$ locale
LANG=en_GB.UTF-8
LC_CTYPE=ru_RU.UTF-8
LC_NUMERIC=en_GB.UTF-8
LC_TIME=en_GB.UTF-8
LC_COLLATE=ru_RU.UTF-8
LC_MONETARY=ru_RU.UTF-8
LC_MESSAGES=en_GB.UTF-8
LC_PAPER=ru_RU.UTF-8
LC_NAME=ru_RU.UTF-8
LC_ADDRESS=ru_RU.UTF-8
LC_TELEPHONE=ru_RU.UTF-8
LC_MEASUREMENT=ru_RU.UTF-8
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=

$ locale -a
C
en_GB.utf8
POSIX
ru_RU.utf8

But man gives the error:

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

If I set the LC_ALL, the error disappears:

$ LC_ALL=en_GB.UTF-8 man
What manual page do you want?

But I don't want to set LC_ALL because I set some LC_ to the other locale.

How to solve this problem with man?

Best Answer

I found this code in the source to man for Debian squeeze:

/* initialise the locale */
    if (!setlocale (LC_ALL, "") && !getenv ("MAN_NO_LOCALE_WARNING"))
        /* Obviously can't translate this. */
        error (0, 0, "can't set the locale; make sure $LC_* and $LANG "
                 "are correct");
    setenv ("MAN_NO_LOCALE_WARNING", "1", 1);

Try setting the environment variable MAN_NO_LOCALE_WARNING to 1 to see if that helps. I'm not sure why setlocale (LC_ALL, "") is failing, according to the documentation for setlocale():

The return value is NULL if the request cannot be honored.
Related Question