Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Unable to read environment locale: exit now. #1886

Closed
tracing-home opened this issue Jun 18, 2018 · 17 comments
Closed

Error: Unable to read environment locale: exit now. #1886

tracing-home opened this issue Jun 18, 2018 · 17 comments

Comments

@tracing-home
Copy link

Hi....
I am getting a consistent

Unable to read environment locale: exit now.

error when trying to run context with this command (set in the create menu)

mtxrun --autogenerate --script context --autopdf --purge --synctex=-1 "%d/%f"

Executing the same command in a terminal works fine. From TextMate also no problems.

Replacing the actual command with a useless
cat "%d/%f"
produces no errors.

I am on MacOS 10.11.6, LANG=de_DE.UTF-8 shows in terminal, below is the debug info.
I do notice the Gtk warning about locale not supported. If I set LANG=en_US.UTF-8 in .profile the error remains the same. What to do?

22:02:13: Gtk WARNING : Locale not supported by C library. Using the fallback 'C' locale. 22:02:13: Geany INFO : Geany 1.33, C 22:02:13: Geany INFO : GTK 2.24.31, GLib 2.52.2 22:02:13: Geany INFO : System data dir: /Applications/Geany.app/Contents/Resources/share/geany 22:02:13: Geany INFO : User config dir: /Users/martin/.config/geany 22:02:13: Geany INFO : System plugin path: /Applications/Geany.app/Contents/Resources/lib/geany 22:02:13: Geany INFO : Added filetype Arduino (61). 22:02:13: Geany INFO : Added filetype Clojure (62). 22:02:13: Geany INFO : Added filetype CUDA (63). 22:02:13: Geany INFO : Added filetype Cython (64). 22:02:13: Geany INFO : Added filetype Genie (65). 22:02:13: Geany INFO : Added filetype Graphviz (66). 22:02:13: Geany INFO : Added filetype JSON (67). 22:02:13: Geany INFO : Added filetype Scala (68). 22:02:13: Geany INFO : Loaded libvte from libvte.9.dylib 22:02:13: Geany INFO : /Users/martin/Documents/daf-Kurse/ABS/Mathe/Schätzen/textaufgabenweg.tex : LaTeX (UTF-8)

@elextr
Copy link
Member

elextr commented Jun 18, 2018

Try a useless command locale or echo $LANG to see if its set.

@tracing-home
Copy link
Author

Thanks for the reply. Well, locale is useful :)

running "locale" in Geany gives

LANG="de.UTF-8"
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL="C"

running in terminal gives:

locale -a |grep de
de_AT
de_AT.ISO8859-1
de_AT.ISO8859-15
de_AT.UTF-8
de_CH
de_CH.ISO8859-1
de_CH.ISO8859-15
de_CH.UTF-8
de_DE
de_DE.ISO8859-1
de_DE.ISO8859-15
de_DE.UTF-8

That shows, the locale "de.UTF-8" geany picks up from somewhere does not exist on my MacOS installation.

in .profile the (overkill) setting of

export LANG="de_DE.UTF-8"
export LC_COLLATE="de_DE.UTF-8"
export LC_CTYPE="de_DE.UTF-8"
export LC_MESSAGES="de_DE.UTF-8"
export LC_MONETARY="de_DE.UTF-8"
export LC_NUMERIC="de_DE.UTF-8"
export LC_TIME="de_DE.UTF-8"
export LC_ALL="de_DE.UTF-8"

is not seen by geany, even after restarting it. running locale again gives the same result

Question: from where does geany pick up "de.UTF-8“, or rather how to provide geany/gtk with a supported locale?

thanks

@elextr
Copy link
Member

elextr commented Jun 19, 2018

Are you running Geany from a shell? I am not a OSXpert, but on linux if you run commands from menus often they don't run in a shell, and then .profile doesn't get read.

@elextr
Copy link
Member

elextr commented Jun 19, 2018

In fact the first line of your debug messages says its a bad locale 22:02:13: Gtk WARNING : Locale not supported by C library. Using the fallback 'C' locale.

@codebrainz
Copy link
Member

@techee

@tracing-home
Copy link
Author

tracing-home commented Jun 19, 2018

@elextr
Thanks for the comments.
Yes, indeed, the debug message points that out, as I said in the initial post. The question remains: what to do about it? The documentation unfortunately gives me no hints on 'locale' setup. It seems that GTK expects a
locale configuration in some other way. The shell/term environment doesn't help:

env |grep UTF
LC_MONETARY=de_DE.UTF-8
LC_NUMERIC=de_DE.UTF-8
LC_ALL=de_DE.UTF-8
LC_MESSAGES=de_DE.UTF-8
LC_COLLATE=de_DE.UTF-8
LANG=de_DE.UTF-8
LC_CTYPE=de_DE.UTF-8
LC_TIME=de_DE.UTF-8

No, I am not starting geany from a shell. Just as an app from the GUI. btw, geany itself appears in German - according to my system setup

However, starting it from the terminal, I see, amongst other errors, the same GTK-Warning:

/Applications/Geany.app/Contents/MacOS/geany textaufgabenweg.tex
2018-06-19 14:46:54.895 defaults[979:23009] 
The domain/default pair of (.GlobalPreferences, AppleCollationOrder) does not exist
/Applications/Geany.app/Contents/MacOS/geany: line 108: test: argument expected

(process:965): Gtk-WARNING **: Locale not supported by C library.
	Using the fallback 'C' locale.
2018-06-19 14:46:55.006 geany-bin[965:22992] *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead. 

the starter is a bash script. That multiple places have a export LANG=....
I suspect one of those sets LANG="de.UTF-8" when it should be setting LANG="de_DE.UTF-8"
There simply is no de.UTF-8 locale on this Mac.

@elextr
Copy link
Member

elextr commented Jun 19, 2018

Sorry outside my OSX knowledge, @techee pinged above is the OSX port maintainer, maybe he can help.

@tracing-home
Copy link
Author

From the starter script
/Applications/Geany.app/Contents/MacOS/geany
I gleaned, if there is an empty file like this:
~/.config/geany/ignore_locale
locale settings default to en_US

if test -e ~/.config/geany/ignore_locale; then
    export LANG="en_US"
    export LC_MESSAGES="en_US"
    export LC_ALL="en_US.UTF-8"
else

That is a workaround! context now builds the PDF. Should this be needed?

@elextr
Copy link
Member

elextr commented Jun 19, 2018

IIRC this feature was implemented because since a lot of software/documentation is in English it is disconcerting to have to swap brain cells back to the application UI in a different locale, So the feature has a deliberate use-case, its just coincidence it provides you a workaround.

@tracing-home
Copy link
Author

Of course, it makes sense to set a default en_US locale. Doing that sets my App Gui to English too. That seems to get unset later, and then using "de" instead of "de_DE" creates the mess.

@techee
Copy link
Member

techee commented Jun 19, 2018

@elextr Defaulting to English isn't done any more because people then complained Geany isn't in their native language. So now you have to create the "config" file to get English locale as @tracing-home did.

@tracing-home How does your "Language and Region" settings looks like? Have a look at mine in the screenshot below and try to execute the same code (which is the code from line 72 of the launcher script):

screen shot 2018-06-19 at 18 21 44

In my case it uses the languages from "Preferred languages", underscore, and the language from the "Region" settings.

@tracing-home
Copy link
Author

tracing-home commented Jun 19, 2018

@techee
Here is my corresponding screenshot. I get essentially the same, with my primary language set to German. The terminal output reflects that. So the geany interface is set to German without they configuration file.

Looking with gets me de_DE as desired locale. locale -a offers that

defaults read .GlobalPreferences AppleLocale
de_DE

If I then add to the bottom of the startup script:

export LANG="de_DE.UTF-8"
export LC_ALL="de_DE.UTF-8"

context can run without a problem. Obviously this is not a solution only a quickfix hack.

So the script ultimately deciding that "de" is the correct locale and not "de_DE" causes the trip-up.

bildschirmfoto 2018-06-19 um 20 08 58

@techee
Copy link
Member

techee commented Jun 19, 2018

Would you try just

defaults read .GlobalPreferences AppleLanguages

to see what you get? Even with the same settings as yours, I get

(
    "de-DE",
    "en-DE",
    "zh-Hant-TW"
)

and filtering this through the sed seems to do the right thing (Do you use the system sed or some other sed, e.g. from homebrew? What does which sed show?).

@tracing-home
Copy link
Author

here it is. essentially the same result. sed seems to be the system one, though I do have homebrew installed.

which sed
/usr/bin/sed
defaults read .GlobalPreferences AppleLanguages
(
    de,
    en,
    "zh-Hant"
)

I wonder what I could have done to the system to get only "de". Actually it is a fairly fresh install. 10.11.6 El Capitain. Asides from a good bit of network blocking (outgoing) it is pretty default.

@techee
Copy link
Member

techee commented Jul 1, 2018

@tracing-home Right, I finally had time to install 10.11 into a virtual machine and it really behaves the way you describe. Stupid there are such differences between OS X versions.

I'm not the author of the launch scripts, I just made some modifications so I'm not sure what other consequences it would have to swap the order of checking AppleLocale and AppleLanguages. But it seems to work here. Would you try to modify the launch script this way:

geany/geany-osx#9

and let me know if it works for you?

@tracing-home
Copy link
Author

@techee Thanks for the effort! These kind of changes are indeed stupid!
The new launcher skript launcher-gtk3.sh works for me! I replaced the original geany with it.
In that sense, I think the problem is solved! Thanks again. I'm leaving it open in case you have any final comments.

@techee
Copy link
Member

techee commented Jul 3, 2018

@tracing-home Great, thanks for testing. Maybe just if you are planning to use it for now, use the gtk2 variant of the script, otherwise you might run into some problems. The currently distributed Geany binaries are based on gtk2 because gtk3 is quite buggy on macOS.

@techee techee closed this as completed Jul 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants