iTerm2 and locale - LANG variable not set

6,343 views
Skip to first unread message

Nick Zavaritsky

unread,
Jan 25, 2011, 11:08:37 AM1/25/11
to iterm2-...@googlegroups.com
Hello everyone!

I run iTerm2 (Build 0.20.20110109) on two nearly identical computers (same OS, same language/regional settings).

First iTerm2 installation was upgraded from the previous version. On a second computer I have a clean installation of iTerm2 (not an upgrade).

Strangely when running the first installation, LANG environment variable is not set hence entering anything except pure ASCII from keyboard doesn't work.

The second installation doesn't have this issue. I copied iTerm2 settings from the second machine (~/Library/Preferences/com.google.iTerm2.plist) but it didn't help.

To confirm that the problem is not caused by different .bashrc-s I did setup a new “bookmark” in iTerm. It runs “env” instead of a login shell. It showed the same results.

Finally I've inspected process tree with ps. As far as I can comprehend, iTerm spawns login process. In the first case it doesn't have LANG environment variable set. In the second case it does. In both cases iTerm itself doesn't have the LANG set.

Any ideas what to check next?

George Nachman

unread,
Jan 25, 2011, 4:02:24 PM1/25/11
to iterm2-...@googlegroups.com
The way the LANG var is set is complicated. Mostly, it is based on the locale that the OS reports. Apple's documentation states this:

The locale is formed from the settings for the current user’s chosen system locale overlaid with any custom settings the user has specified in System Preferences.

If your system's setlocale(3) does not accept either the language (like "en_US") or the language concatenated with the encoding (like "en_US.UTF-8") then no LANG is set.

Check that the contents of /usr/share/locale are the same on both machines.

Nick Zavaritsky

unread,
Jan 26, 2011, 8:11:36 AM1/26/11
to iterm2-...@googlegroups.com
The mystery is finally solved!

After all I discovered that regional settings of my two computers were slightly different.
In particular the one I was having issues with iTerm listed “Russia” under “Region” listbox of “Formats” tab of “Language&Text”. The other one where iTerm was running smoothly listed “USA”. Initially I believed that only interface language settings matter (“Language” tab) thats why I was that clueless.

I do see now that “Formats” select the locale, that's pretty natural. Thats why I get “en_US.UTF-8” when switching my region to “USA”.

Is it possible that iTerm is somehow confused when interface language settings don't match the selected region? I've just verified and ru_RU.UTF-8 is present in my /usr/share/locale.

The strange thing is that System Preferences doesn't allow me to select “Russia” once I've selected “USA”, so probably Apple itself doesn't support having mismatched interface language and the locale. 

The reason I do setup my computer that way is because I hate typing localized folder names in terminal and localized compiler error messages are misleading.
 
I understand that interface language is technically a part of locale hence my initial setup was somewhat weird.

George Nachman

unread,
Jan 26, 2011, 2:42:15 PM1/26/11
to iterm2-...@googlegroups.com
I think you're correct: if you have a combination of language and country that there is no locale for, the LANG variable is set. If you manually set the LANG var to an unorthodox combination like ru_US, does it work as you would expect?
Reply all
Reply to author
Forward
0 new messages