I've done all of the searching that I can, and I think I've read the right answer, but am too dumb to know that I read it.
I can't seem to figure out the magic tricks to get Lua modules, installed by luarocks or by any other means, to show up in LuaLaTeX. So here is a minimal:
%!TEX TS-program = lualatex
\documentclass{article}
\usepackage{luatexbase}
\usepackage{luacode}
\begin{document}
\directlua{package.path = "~/.luarocks/share/lua/5.1/?.lua;~/.luarocks/share/lua/5.1/?/init.lua;" .. package.path }
\directlua{require('pl')}
\directlua{require('htk')}
\directlua{tex.sprint(package.path)}
the standard approximation $\pi = \directlua{tex.sprint(math.pi)}$
\end{document}
In installed htk using luarocks with the command luarocks --local install HTK
. The Penlight module was installed the same way, except with penlight. Penlight uses the "pl/submodulename" scheme and htk uses just "htk.lua" in the ~/.luarocks/share/lua/5.1
directory.
The log output is:
./luamoduleload.tex:9: LuaTeX error <\directlua >:1: module 'pl' not found:
no field package.preload['pl']
[luatexbase.loader] Search failed
[kpse lua searcher] file not found: 'pl'
[kpse C searcher] file not found: 'pl'
stack traceback:
[C]: in function 'require'
<\directlua >:1: in main chunk.
l.9 \directlua{require('pl')}
The lua interpreter ran into a problem, so the
remainder of this lua chunk will be ignored.
./luamoduleload.tex:10: LuaTeX error <\directlua >:1: module 'htk' not found:
no field package.preload['htk']
[luatexbase.loader] Search failed
[kpse lua searcher] file not found: 'htk'
[kpse C searcher] file not found: 'htk'
stack traceback:
[C]: in function 'require'
<\directlua >:1: in main chunk.
l.10 \directlua{require('htk')}
The lua interpreter ran into a problem, so the
remainder of this lua chunk will be ignored.
Would more of the log file be helpful?
In truth, if i just knew where to instal the lua modules that I want to use, I'd be a happy camper, especially if I don't need to do any magic tricks to get stand-alone lua scripts to work outside of LuaLaTeX.
Please let me know if I can be any clearer or if I'm not reading the right fine manuals. :)
-Andrew
texmf.cnfsays:% Lua needs to look for binary lua libraries distributed with packages. CLUAINPUTS = .;$SELFAUTOLOC/lib/{$progname,$engine,}/lua//. Perhaps you can add the location where luarocks adds libraries to CLUAINPUTS. – Aditya Mar 27 '11 at 20:34CLUAINPUTS = .;$SELFAUTOLOC/lib/{$progname,$engine,}/lua//;~/.luarocks/share/lua/5.1//and it appears to have no effect... Cry ;) – Andrew Starks Mar 28 '11 at 04:55.sofile in the current directory to see if dynamic loading works at all. – Aditya Mar 28 '11 at 13:12\directlua{require('pl')}and the log-file would be useful too. E.g. I can't understand where the reference tooberdiek.luatex.kpse_module_loadercomes from. – Ulrike Fischer Mar 28 '11 at 14:34~in texmf.cnf files. Does it work if you replace~with$HOMEor the complete path? – Aditya Mar 28 '11 at 23:13.texfile, if I editpackage.pathto use\$HOME, I getTeX capacity exceeded, sorry [input size=5000].– Andrew Starks Mar 29 '11 at 13:49