Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a lua file that I would use in many of my TeX's documents, loading it with dofile().

I thought it was ok if I simply put it in the (local) texmf tree*, but this doesn't work. Instead I have the following error message :

LuaTeX error cannot open the mycode.lua: No such file or directory

Is there any nice solution ?

  • I try to save the file in ~/Library/texmf, in ~/Library/texmf/tex, ~/Library/texmf/tex/latex and even in ~/Library/texmf/lua (I had to create the directory).
share|improve this question
1  
Where precisely did you save the file? –  egreg Oct 4 '11 at 13:43
    
How do you load the file? require()? dofile()? –  topskip Oct 4 '11 at 13:45
    
Placing file.lua in the same folder and loading with dofile("file.lua") works, but I'd also be interested in a more general solution (especially since dofile("/path/to/file.lua") doesn't seem to work). –  scallops Oct 4 '11 at 13:51
    
@scallops of course it works, but it isn't a nice and general solution at all. So we have to wait for the gurus :) –  Matsaya Oct 4 '11 at 13:53
2  
require() should normally use kpse. E.g. require("fontspec.lua") finds fontspec.lua in tex\latex\fontspec. –  Ulrike Fischer Oct 4 '11 at 14:12
show 1 more comment

3 Answers

up vote 13 down vote accepted

dofile() expects full path (or path relative to current directory). You have to either use require() which will search TEXMF tree, or use kpse.find_file() and pass the returned path to dofile(). kpsewhich -show-path=lua should show the search path for lua files.

share|improve this answer
add comment

require() searches (TeXlive2011, LuaLaTeX) in these texmf subdirectories:

scripts/lualatex/lua/
scripts/luatex/lua
scripts/lua
scripts/lualatex
scripts/luatex
scripts
tex/lualatex
tex/latex
tex/luatex
tex/generic
tex
share|improve this answer
add comment

require() should normally use kpse. E.g. require("fontspec.lua") finds fontspec.lua in tex\latex\fontspec.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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