23

I typed man sudoers but got

man: can't set the locale; make sure $LC_* and $LANG are correct
No manual entry for sudoers

What does this mean?

1
  • I had similar problem on OS X and was able to fix it by commenting out SendEnv LANG LC_* in /etc/ssh/ssh_config.
    – Ilya I
    Oct 15, 2015 at 7:00

6 Answers 6

13

Your locale isn't set. In Debian-Base you should use dpkg-reconfigure locales to set it.

Some of packages depend on locales package and its variable such as LC_* series ...!

It means $LANG is empty.

1
  • 3
    On my system $LANG wasn't empty when I got the message from man. I ran dpkg-reconfigure locales and let it process, but nothing changed.
    – Vince
    Sep 5, 2020 at 3:11
9

Your locale settings as indicated by environment variables uses locale names that are not available on your system.

Locale settings control the character set used by commands and terminals (LC_CTYPE), the collation order (LC_COLLATE), the format of dates (LC_TIME), numbers (LC_NUMERIC) and amounts of currency (LC_MONETARY), the language of messages (LC_MESSAGES), etc. The values of these variables are locale names. On most systems, the name has the form xx_YY or xx_YY@variant or xx_YY.charset where xx is a two-letter language code and YY is a two-letter country code.

Run the command locale to see your current settings. Run locale -a to see the available locale names.

If the locale you'd like to use is missing, you may need to generate it. This is distribution-dependent. For example, on Debian, run dpkg-reconfigure locales as root. On Ubuntu, run locale-gen xx_YY to generate the locale xx_YY.

3

Below is an addition to the recommendation to use dpkg-reconfigure locales, which failed for me (my hunch is that if it were working, I wouldn't have this problem.

The problem

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

First try to solve it, fails

me@pc:~$ sudo dpkg-reconfigure locales
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LANG = "en_US"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
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
Generating locales...
  en_AG.UTF-8... up-to-date
  ...(lines omitted)...

Second try, succeeds. I still get an error on en_ZW, but I don't use it.

me@pc:~$ sudo locale-gen en_US en_US.UTF-8 && sudo dpkg-reconfigure locales
...
me@pc:~$ man
what manual page do you want?

No more LOCALE errors on the man command!

2

This means your system does not know in which language the info should be displayed.

Paste the output of locale -a probably you haven`t generated the locales this is a bit distro specific but usually running locale-gen will generate the locales for you hence removing the error. Take a look on this link.

1

Still a problem in 2020... On my system (Kubuntu 20.04.1), the solution was simply export LC_ALL=en_US.UTF-8 in my ~/.zshrc. I imagine the same would work in .bashrc.

I think there are other variables which need to be set (probably those reported by locales), but they seem to have all been handled by the desktop environment.

-1

If you're using a raspberry pi, this can also be fixed by using sudo raspi-config, selecting "Localisation Options", and then setting your appropriate locale.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .