20

Note: The question is not about how to change the locale, or what is the locale. The question is about why is there a locale-based error in man in 10.3, but no error in 12.6, even though the locales are identical in both cases.


After running man, reading a manual entry and closing it, I receive the following error

$ man curl                     # The manual opens, I read it, then close
Unknown locale, assuming C
$ man zsh                      # The manual opens, I read it, then close
Unknown locale, assuming C

The manual pages work correctly, and can be browsed, but I have no idea where the error comes from, and it is rather annoying.

This is what I obtain when running locale

$ locale
LANG=""
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=

I'm using Ventura 13.0. The same error does not happen in 12.6 even though the locale is identical (see below), so I do not think that it is an issue with locale, but rather an issue with man.

Note that locale says

   LANG         Used as a substitute for any unset LC_* variable.   \  
If LANG is unset, it will act as if set to "C".  If any of LANG or  \  
LC_* are set to invalid values, locale acts as if they are all unset.

so there should be no error, LANG should be automatically set to C.

EDIT:

Some new insight. I ran the same commands on two computers.

Computer 1 runs 13.0 outputs the error.
This computer has man for MacOS 13.0 from January 9 2021.

Computer 2 runs 12.6 and outputs no error.
This computer has man version 1.6g from September 19 2005.

The output of the locale command is completely identical on both computers, in particular they both have LC_CTYPE="UTF-8".

Could it be a man bug?

9
  • 1
    Does apple.stackexchange.com/a/21107/237 help?
    – mmmmmm
    Nov 24, 2022 at 10:17
  • 1
    No. I use iTerm, but neither iTerm nor Terminal change their behaviour when this setting is changed.
    – Kolja
    Nov 24, 2022 at 14:10
  • 1
    Why are you setting it to "C"? That's not the default, it should be using one of the UTF-8 locales (depending on your language) unless you changed it somewhere. Nov 24, 2022 at 15:44
  • 3
    I don't recall ever changing locale. Either this was the default, or I installed some shady brew package that changed these settings. I wiped my system one month ago, and I don't recall doing anything that had to do with changing the locale since reinstalling the OS. The only thing I could think of is having installed TeX, or new keyboards with Ukelele, but I don't see how that could impact the locale settings.
    – Kolja
    Nov 25, 2022 at 10:10
  • 1
    Reopened. But the question asks "why is there no error on 13.0 but one on 12.6" while the Edit part towards the end mentions "13.0 outputs the error, 12.6 outputs no error". Can you please fix this?
    – nohillside
    Dec 15, 2022 at 12:33

4 Answers 4

22

Terminal
Select menu Terminal > Settings....
In the window goto Profiles and the tab Advanced.
At the bottom deselect the option: Set locale environment variables on startup
Do this for all the profiles you use.

iTerm2
Select menu iTerm2 > Settings....
In the window goto Profiles and the tab Terminal.
At the bottom deselect the option: Set locale variables automatically
Do this for all the profiles you use.

Still odd that this should be the fix.
According to the Tooltip in iTerm:

LANG and LC_CTYPE may be set if this is enabled. If you have an unusual setting of country and language then disabling this may help.

So, the root-cause must be the locale settings that got screwed over during the upgrade to 13.0.*. I'm guessing the best fix is to set LANG and LC_CTYPE to something more useful (UTF-8 perhaps, as suggested elsewhere).

1
  • 3
    Thanks. This, as mentioned in the above comment, solves the problem. However, I am then unable to write in other languages in the terminal. Not that I would use them in the terminal, but it is annoying when the command prompt outputs hex codes instead of letters when typing. The only difference between selecting and deselecting the "Set locale variables automatically" is that LC_CTYPE is set to UTF-8 when selected, and C when deselected. However when setting export LANG=en_US.UTF-8 everything works fine, and there are no errors from man.
    – Kolja
    Dec 10, 2022 at 11:41
6

I have this issue too and I did some digging. macOS ventura is delivered in this state, it is not due to homebrew or what not. Confirmed in an empty VM. Thought other readers may want to know this.

Disabling the "Set locale environment variables on startup" works As does setting "export LANG=en_US.UTF-8". Both are comments above.

My guess is the maximum compatibility is achieved with solution #2.

1
  • The ordering of the answers is not the same for all users. If you need to refer to a specific one, please link accordingly. You can use the Share button beneath an answer to get its URL.
    – nohillside
    Dec 24, 2022 at 10:09
3

One thing that can help resolve the issue:

Open your .zshrc file in a text editor, or .bash_profile depending on which one you're using.

Add the following lines to the file:

export LANG="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"

Save and close the file.

Restart your terminal or run source ~/.zshrc, or source ~/.bash_profile in the terminal to apply the changes.


If you want to use everything in English but also want your mother tongue characters to be displayed correctly, you can set the LC_CTYPE environment variable to your mother tongue locale while keeping the other locale-related environment variables set to an English locale such as en_US.UTF-8. This will tell the system to use the English language for most things, but use your mother tongue character set for displaying characters.


There is also LC_ALL environment variable that can be used to override the values of all other locale-related environment variables. However, setting it can have unintended consequences, as it overrides all other locale settings. Therefore, it’s generally recommended to leave LC_ALL unset.

2

The answer in https://apple.stackexchange.com/a/21107/237 is the correct one.

You have this turned off: enter image description here

2
  • 3
    Thanks! However what's happening is rather the opposite. This setting was turned ON. After turning it off, the error disappears. So this does indeed solve the problem, I must have made a mistake when checking the comment by @mmmmmm . However, the problem, to a certain extent, is not fully solved. The difference in the new locale is that LC_CTYPE is set to UTF-8 and everything else is the same. Why does this create an error in man?
    – Kolja
    Nov 26, 2022 at 22:36
  • 1
    This fixes it for Terminal. But not for iTerm2
    – Mausy5043
    Dec 10, 2022 at 9:59

You must log in to answer this question.

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