<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 10 Nov 2022 at 05:11, Werner LEMBERG <<a href="mailto:wl@gnu.org">wl@gnu.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
[I don't know the exact luatex version, sorry]<br>
<br>
<br>
Folks,<br>
<br>
<br>
I get the very annoying and extremely unhelpful error message<br>
<br>
```<br>
Unable to read environment locale:exit now.<br>
```<br>
<br>
This is from a CI container where I can't easily call `locale` to find<br>
out more details. Additionally, looking up this problem in the<br>
internet, it seems that luatex is sensitive to very subtle details<br>
that can easily be missed (for example, `-` vs. `_`).<br>
<br>
Is there a way to make luatex tell me what exactly the problem is?<br>
<br></blockquote><div><br></div><div>This is the part of luainit.c where luatex calls setlocale:</div><div><br></div><div> /*tex<br> Get the current locale (it should be |C|) and save |LC_CTYPE|, |LC_COLLATE|<br> and |LC_NUMERIC|. Later |luainterpreter()| will consciously use them.<br> */<br> old_locale = xstrdup(setlocale (LC_ALL, NULL));<br> lc_ctype = NULL;<br> lc_collate = NULL;<br> lc_numeric = NULL;<br> if (old_locale) {<br> /*tex<br> If |setlocale| fails here, then the state could be compromised, and<br> we exit.<br> */<br> env_locale = setlocale (LC_ALL, "");<br> if (!env_locale && !lua_only) {<br> fprintf(stderr,"Unable to read environment locale: exit now.\n");<br> exit(1);<br> }<br> tmp = setlocale (LC_CTYPE, NULL);<br> if (tmp) {<br> lc_ctype = xstrdup(tmp);<br> }<br> tmp = setlocale (LC_COLLATE, NULL);<br> if (tmp) {<br> lc_collate = xstrdup(tmp);<br> }<br> tmp = setlocale (LC_NUMERIC, NULL);<br> if (tmp) {<br> lc_numeric = xstrdup(tmp);<br> }<br> /*tex<br> Return to the previous locale if possible, otherwise it's a serious<br> error and we exit: we can't ensure a 'sane' locale for lua.<br> */<br> env_locale = setlocale (LC_ALL, old_locale);<br> if (!env_locale) {<br> fprintf(stderr,"Unable to restore original locale %s: exit now.\n",old_locale);<br> exit(1);<br> }<br> xfree(old_locale);<br> } else {<br> fprintf(stderr,"Unable to store environment locale.\n");<br> }<br> /*tex make sure that the locale is 'sane' (for lua) */<br> putenv(LC_CTYPE_C);<br> putenv(LC_COLLATE_C);<br> putenv(LC_NUMERIC_C);<br></div><div><br></div><div> --</div><div>luigi</div></div></div>