Wrong messages after setting LANG et al.

41 views
Skip to first unread message

Arash Esbati

unread,
Mar 5, 2026, 3:35:10 PMMar 5
to iterm2-...@googlegroups.com
Hi all,

first of all, many thanks for iTerm2, great tool! I'm using iTerm2
Build 3.6.8 installed via homebrew and it seems I'm not able to change
the $LANG for messages emitted by bash.

I have German as primary language for my macOS, but have these lines in
my .bashrc:

export LANG=en_US.UTF-8
export LC_MESSAGES=en_US.UTF-8
export LC_MONETARY=de_DE.UTF-8

Running locale in bash returns:

$ locale
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL=

I think I also told iTerm2 not to fiddle with the language with this
setting:
iterm2.png

George Nachman

unread,
Mar 6, 2026, 6:49:29 PMMar 6
to iterm2-...@googlegroups.com
If you start bash within bash, does that one give you English messages? Perhaps the issue is that the environment is set to German at the time bash starts and it doesn’t update its own locale when you assign to LANG. If that is the case, then try setting the local to “Custom locale” and pick US English:


--
You received this message because you are subscribed to the Google Groups "iterm2-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-discus...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/iterm2-discuss/m2qzpyqati.fsf%40macmutant.fritz.box.



Still, when I enter a wrong command name in bash, say 'lo RET', I get:

 $ lo
 -bash: lo: Kommando nicht gefunden

Any hint what I'm doing wrong?

Best, Arash

--
You received this message because you are subscribed to the Google Groups "iterm2-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-discus...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/iterm2-discuss/m2qzpyqati.fsf%40macmutant.fritz.box.

Arash Esbati

unread,
Mar 7, 2026, 8:06:54 AMMar 7
to iterm2-...@googlegroups.com
George Nachman <gnac...@llamas.org> writes:

> If you start bash within bash, does that one give you English
> messages?

Yes, it does.

> Perhaps the issue is that the environment is set to German at the time
> bash starts and it doesn’t update its own locale when you assign to
> LANG. If that is the case, then try setting the local to “Custom
> locale” and pick US English:

Yes, that does the trick. Again, many thanks for maintaining iTerm2.

Best, Arash

John Simpson

unread,
Apr 15, 2026, 10:11:50 PMApr 15
to iterm2-...@googlegroups.com
> <iterm2.png>
> Still, when I enter a wrong command name in bash, say 'lo RET', I get:
>
> $ lo
> -bash: lo: Kommando nicht gefunden
>
> Any hint what I'm doing wrong?


Short version:

* The OS is telling iTerm2 to run in German.
* iTerm2 is telling your shell to start in German.
* Your `.bashrc` configures your shell to start its child processes in English, but cannot change the language that the shell itself runs in.

So the shell itself is running in German, but the programs that the shell runs (such as `locale` or `env`) will be started in English.

If you want the shell itself to run in English (i.e. "command not found" instead of "Kommando nicht gefunden"), here are a few ways to do it:

* Configure iTerm2 to run the shell in English, i.e. with "LANG=en_US.UTF-8". In iTerm2's settings:
* Change "Environment:" to "Use custom locale..."
* Use the "Change..." button and select "English (United States), UTF-8"

* Add something to your `.bashrc` file so that, if the shell doesn't have the correct `LANG` value, it exports the correct value and executes a new shell process over the current shell. It might look something like this, at the top of the file:

if [[ "$LANG" != "de_DE.UTF-8" ]]
then
LANG="de_DE.UTF-8" exec "$SHELL" -l
fi

----------------------------------------

Details:

(1) Each process has its own set of environment variable. When a parent process creates a child process, it gives the child the list of variables that it starts with.

(2) Unless you deliberately did something strange, the main iTerm2 process will be a child of `launchd`. When `launchd` starts iTerm2, it sends the `LANG` variable with the appropriate value for the system's primary language.

(3) When a window or tab opens, iTerm2 starts a shell in that window/tab. It may or may not send the shell a `LANG` environment variable, depending on the "Environment:" setting from your screenshot.

(4) In your case, the shell is starting with "LANG=de_DE.UTF-8".

(5) There is no way to make `bash` re-configure its own locale after it has been started. The closest thing you can do is start a new instance of bash with the new `LANG` value.

It *looks like* when you use the "Do not set locale environment variables", the `LANG` value it sends to the shell is the same value that iTerm2 inherits from `launchd`. I'm not sure if this is a bug or not, but at the very least the description isn't 100% correct.

* With the option "Do not set locale environment variables" and label `$LANG will not be set`, I would assume that iTerm2 *removes* the `LANG` and `LC_xxx` variables from the environment block it gives the shell.

* If iTerm's intent is to *copy* whatever values iTerm2 inherited from `launchd`, I would probably have called the option "Do not *change* locale environment variables", with the label `$LANG will keep the system-wide value`.


Other things to point out:

* The `locale` command shows you the *effective* settings, whether the underlying environment variables are set or not. Run `env` to see which variables are actually set, and which values are implied.

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

$ env | grep '^L[AC]'
LANG=en_US.UTF-8
LC_TERMINAL=iTerm2
LC_TERMINAL_VERSION=3.6.9

* The command `pstree -s iTerm` will show the chain of parent/child relationships involving iTerm2. Seeing this may help you to "visualize" how the `LANG` value makes its way from `launchd` down to the shell.

* If you don't have the `pstree` command, you can install it using Homebrew, using `brew install pstree`. (This is one of the standard packages I install on all of my macOS machines.)

Good luck.

--
John Simpson - KG4ZOW
https://jms1.net/

Reply all
Reply to author
Forward
0 new messages