Discussion:
Making lua modules findable
(too old to reply)
Ralf Meyer
2018-01-05 11:28:32 UTC
Permalink
Dear texlive developers,

with luatex it becomes possible to embed lua modules in luatex
documents.  Many such modules are listed at luarocks.org, and quite a
few can be useful in luatex.  For normal users, this is too complicated
in texlive 2017 because of search path differences.  I suggest to change
the configuration of kpathsea in a new release of texlive so that luatex
searches lua modules also in the standard folders for lua modules.  This
is currently not the case, which creates an extra hurdle to use
general-purpose lua modules in luatex documents.  On my ubuntu system,
luarocks installs modules in /usr/local/share/lua and
/usr/local/lib/lua. And lua -e "print(package.path)" and lua -e
"print(package.cpath)" shows several more paths.  Or maybe you know an
even better way to make lua modules in these folders findable by luatex
as automatically as possible.

Yours,

Ralf Meyer
Reinhard Kotucha
2018-01-05 21:25:02 UTC
Permalink
Post by Ralf Meyer
Dear texlive developers,
with luatex it becomes possible to embed lua modules in luatex
documents.  Many such modules are listed at luarocks.org, and quite
a few can be useful in luatex.  For normal users, this is too
complicated in texlive 2017 because of search path differences.  I
suggest to change the configuration of kpathsea in a new release of
texlive so that luatex searches lua modules also in the standard
folders for lua modules.  This is currently not the case, which
creates an extra hurdle to use general-purpose lua modules in
luatex documents.  On my ubuntu system, luarocks installs modules
in /usr/local/share/lua and /usr/local/lib/lua. And lua -e
"print(package.path)" and lua -e "print(package.cpath)" shows
several more paths.  Or maybe you know an even better way to make
lua modules in these folders findable by luatex as automatically as
possible.
Hi Ralf,

in this case kpathsea isn't involved at all. kpathsea looks for Lua
libraries in $TEXMF _additionally_. From texmf-dist/web2c/texmf.cnf:

% Lua needs to look for binary lua libraries distributed with packages.
CLUAINPUTS = .;$SELFAUTOLOC/lib/{$progname,$engine,}/lua//

You could add other search path there but this is probaly not what you
want.

The variables package.path and package.cpath you have in mind are
compiled into the luatex binary. And variables can be changed at any
time.

Since luatex is currently based on Lua 5.2, the appropriate
directories are /usr/local/{lib,share}/lua/5.2/... . If it's too
difficult to tell luarocks to install libraries there, the best
solution is to add paths to package.path and package.cpath in your lua
scripts before any package is loaded.

The attached script hopefully does what you need:
Karl Berry
2018-01-05 22:27:23 UTC
Permalink
lua -e "print(package.path)" and lua -e
"print(package.cpath)"

I can agree that making it easier to add the "standard Lua directories"
to the Lua search path would be useful.

However, I can't feasibly add a large random set of directories
determined at runtime to the kpathsea search paths.

I don't know if luatex itself can reasonably look up and add those
paths, but it might be more plausible.

In any case, I think adding such directories should be optional, and off
by default, rather than "automatic"ally done. Otherwise debugging
anything becomes substantially more complex, it seems to me. --best, karl.
Loading...