I had my miktex 2.9 working fine with lualatex. I went in and somewhere modified some file so that I could add my own module paths. After upgrading some packages using the miktex upgrade tool my latex code can no longer find my lua modules. When I upgraded miktex said it needed to repair some miktex config file but I didn't realize at the time it was due to my modification.

lualatex does not use LUA_PATH for some reason. My lua library code works standalone just fine(printing package.path shows what is in LUA_PATH but not using lualatex).

I've tried modifying package.path using \directlua and it prints out correctly BUT my modules are still not found.

I've searched the complete miktex installation for lua path stuff and can't find anything. Not sure if the "repair" deleted the file I modified or what happened but nothing seems to work.

In any case, why doesn't lualatex use LUA_PATH? Is there any way to fix this?

The main thing to realize here is that everything worked before "upgrading"(I do not think I upgraded anything regarding lualatex though), everything works as expected using Lua For Windows, and it seems to be a path issue. It seems like it is almost surely an issue with LuaLatex and IIRC the reason I had to modify the path inside the the miktex installation dir was because I couldn't get LUA_PATH or package.path to work with lualatex in the first place

The hard coded solution(which will probably break after each upgrade) is to modify lualatex.ini and add additional paths BUT make sure to use forward slashes and to use two slashes at the end of the path. There is no need to add filenames to the end such as ?.lua like LUA_PATH. There still is the question of why lualatex does not use LUA_PATH.

Also, I am using winedt 6 which may use it's own environment where LUA_PATH does not exst...


Well I have no idea what you changed but to sort things a bit: There are two lualatex.ini files in a normal miktex:

  1. The first is in \miktex\config. The .ini files in this folder contain configuration settings for the binaries, e.g. main_memory or path settings. You can create or open a local version of such an .ini file by using initexmf --edit-config-file=lualatex. Imho lualatex.exe will read both .ini files: the global and the local one and assemble their settings but I never really tested this assumption.
  2. The second lualatex.ini is in \tex\latex\latexconfig. This is the .ini used to generate the format. You can create a local version by copying the file to a local tree in a similar location. If you have a local version it will be used and the global version is ignored.

You should never manipulate the original files installed by miktex (including files of packages) as miktex has tools to check for such changes and then will "repair" the files.

  • You have heard of "Never say never"? – Uiy May 13 '12 at 15:52

In any case, why doesn't lualatex use LUA_PATH? Is there any way to fix this?

Because TeX only ever searches in its own distribution.

See the related question: Installing Lua Modules for use in LuaLaTeX - the sequel

And it's hard to tell why it was working before.

  • It was working before because I modified lualatex.ini and told it to search the paths. When I tried this earlier I guess I didn't use the correct format and it didn't work. From your answer it seems the only way to do this is either to modify require or edit the ini file. – Uiy May 10 '12 at 6:09
  • @Uiy either way you'll shoot yourself into your feet. Unless you remember what you are doing and re-do everything on every update. – topskip May 10 '12 at 6:15
  • That is why I created the question... so if I do forget next time I'll be able to come on here and find the answer. – Uiy May 10 '12 at 6:19
  • @Uiy The usual advice is not to change any of the files in the 'managed' tree precisely because they may be over-written in an update. I'm not sure if it works, but did you try making a copy of lualatex.ini in a local folder? (In MiKTeX, you have to add a localtexmf manually using the MiKTeX config tool.) – Joseph Wright May 10 '12 at 6:19
  • @JosephWright No, But I'm sure it will work. I watched lualatex.exe loading up files and it searched several locations for lualatex.ini and many were user folders. At the time I just didn't know that it was the file to modify(I tried but because I added ?.lua at the end it didn't work so I thought I was editing the wrong file). – Uiy May 10 '12 at 6:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.