[luatex] MySQL driver not found from inside LuaLaTeX
Andreas Matthias
andreas.matthias at gmail.com
Wed Feb 28 21:38:44 CET 2024
<sergei.naumov at gmail.com> wrote:
>
> Thanks, Andreas!
> It's still a bit unclear. I went to my /usr/share/texmf-local (because adding lines into texmf-dist/web2c/texmf.cnf is bad) and created texmf.cfg with the following
>
> LUAINPUTS = $LUAINPUTS;/usr/share/lua/5.3//
> CLUAINPUTS = $CLUAINPUTS:/usr/lib64/lua/5.3//
My texmf.cnf contains the following:
LUAROCKS_PATH = ~/.luarocks/share/lua/5.3
LUAROCKS_CPATH= ~/.luarocks/lib/lua/5.3
% Note: use --shell-escape to run binary lua libraries
LUAINPUTS = $TEXMFDOTDIR;$TEXMF/scripts/{$progname,$engine,}/{lua,}//;$TEXMF/tex/
{luatex,plain,generic,latex,}//;$LUAROCKS_PATH//
CLUAINPUTS =
$TEXMFDOTDIR;$SELFAUTOLOC/lib/{$progname,$engine,}/lua//;$LUAROCKS_CPATH//
% lualatex
LUAINPUTS.lualatex =
$TEXMFDOTDIR;$TEXMF/scripts/{$progname,$engine,}/{lua,}//;$TEXMF/tex/{lualatex,latex,luatex,generic,}//;$LUAROCKS_PATH//
Now create a file test.lua:
kpse.set_program_name('lualatex')
local loader = require('luapackageloader')
loader.add_lua_searchers()
print(package.path)
And run:
texlua test.lua
This should print the package.path including your luarocks path.
Now you can try it with a LaTeX file:
\documentclass{article}
\usepackage{luapackageloader}
\begin{document}
\directlua{
print(package.path)
local serpent = require('serpent')
local foo = {a=1, b='foo'}
print()
print(serpent.dump(foo))
}
\end{document}
This should dump table "foo" onto the console.
> Then you mention luapackageloader in the context of a Lua syntax, so it looks like it is a Luarocks package. But there is no such package. There is a LaTeX package with this name just as Faheem mentions. So, I added \usepackage{luapackageloader} which from its documentation suggests that it adds necessary search paths:
The package "luapackageloader" contains "luapackageloader.sty" as well
as "luapckageloader.lua".
If you are writing your code in a lua-file, then require the lua-file.
If you writing the code directly in
your LaTeX files then load the sty-file.
Andreas
More information about the luatex
mailing list.