Archlinux 上的 LuaLaTeX 和 LuaSQL

LuaLaTeX with LuaSQL on Archlinux

我正在处理一个 LuaLaTeX 文件,该文件将使用 LuaSQL 从我的数据库中获取数据。所以这是我想出的 003-v1.tex003-v1.lua 文件:

003-v1.tex 文件:

\documentclass{article}
\usepackage{luacode}

% Lua kodo vpišemo v ločeno datoteko zaradi syntax highlithing
\directlua{dofile('003-v1.lua')}

\newcommand{\stranke}{\luadirect{stranke()}}

\begin{document}
    \begin{tabular}{ll}
        \hline
        id stranke & ime \
        \hline
        \stranke
        \hline
    \end{tabular}
\end{document} 

003-v1.lua 文件:

function stranke ()

    package.cpath = package.cpath .. ";/usr/lib/i386-linux-gnu/lua/5.1/?.so"
    luasql = require "luasql.mysql"

    env = assert (luasql.mysql())
    con = assert (env:connect("linux_krozki","root","mypassword"))
    cur = assert (con:execute("SELECT * FROM stranke"))

    vnos = cur:fetch ({}, "a")

    while vnos do

        print(
            string.format([[%s & %s \]], vnos.id_stranke, vnos.ime)
        )
        vnos = cur:fetch (vnos, "a")

    end 

end

这个文件应该可以工作,但是当我尝试使用 lualatex 003-v1.tex 进行编译时,出现错误:

This is LuaTeX, Version 1.0.4 (TeX Live 2017/Arch Linux) 
 restricted system commands enabled.
(./003-v1.tex
LaTeX2e <2017-04-15>
(using write cache: /home/ziga/.texlive/texmf-var/luatex-cache/generic)(using r
ead cache: /var/lib/texmf/luatex-cache/generic /home/ziga/.texlive/texmf-var/lu
atex-cache/generic)
luaotfload | main : initialization completed in 0.144 seconds
Babel <3.12> and hyphenation patterns for 1 language(s) loaded.
(/usr/share/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texmf-dist/tex/latex/base/size10.clo(load luc: /home/ziga/.texlive/
texmf-var/luatex-cache/generic/fonts/otl/lmroman10-regular.luc)))
(/usr/share/texmf-dist/tex/lualatex/luacode/luacode.sty
(/usr/share/texmf-dist/tex/generic/oberdiek/ifluatex.sty)
(/usr/share/texmf-dist/tex/luatex/luatexbase/luatexbase.sty
(/usr/share/texmf-dist/tex/luatex/ctablestack/ctablestack.sty))) (./003-v1.aux)
003-v1.lua:8: module 'luasql.mysql' not found:
        no field package.preload['luasql.mysql']
        [kpse lua searcher] file not found: 'luasql.mysql'
        [kpse C searcher] file not found: 'luasql.mysql'
        no file '/usr/local/lib/lua/5.2/luasql.so'
        no file '/usr/local/lib/lua/5.2/loadall.so'
        no file './luasql.so'
        no file '/usr/lib/i386-linux-gnu/lua/5.1/luasql.so'
stack traceback:
        [C]: in function 'require'
        003-v1.lua:8: in function 'stranke'
        [\directlua]:1: in main chunk.
\luadirect ... { \luacode@maybe@printdbg {#1} #1 }

l.14         \stranke

并且根据 this topic 这个错误是因为 LuaLaTeX 不能加载模块 luasql.mysqllua 可以自己加载。我怎么知道的?如果我在用 lua 003-v1.lua 编译之前从 003-v1.lua 注释掉第一行 (function stranke ()) 和最后一行 (end),我得到一个完全没问题的输出:

1 & Žiga \
2 & Ranja \
3 & Romana \

所以我的问题是,如何确保模块 luasql.mysql 在调用 LuaLateX 时加载?我在 Archlinux 上,正在使用 texlive。我听说人们在支持 luasql 的情况下再次编译 texlive,但找不到分步指南......那太棒了!如果有人已经编译好了就更好了


这是关于我的 Texlive 版本的信息:

[ziga@laptop ~]$ pacman -Qs tex | grep live
local/texlive-bibtexextra 2017.44915-1 (texlive-most)                                                                                                                          
local/texlive-bin 2017.44590-2                                                                                                                                                 
local/texlive-core 2017.44918-1 (texlive-most)
local/texlive-fontsextra 2017.44818-1 (texlive-most)
local/texlive-formatsextra 2017.44177-2 (texlive-most)
local/texlive-games 2017.44131-1 (texlive-most)
local/texlive-humanities 2017.44833-1 (texlive-most)
local/texlive-langchinese 2017.44333-1 (texlive-lang)
local/texlive-langcyrillic 2017.44895-1 (texlive-lang)
local/texlive-langextra 2017.44908-1 (texlive-lang)
local/texlive-langgreek 2017.44917-1 (texlive-lang)
local/texlive-langjapanese 2017.44914-1 (texlive-lang)
local/texlive-langkorean 2017.44467-1 (texlive-lang)
local/texlive-latexextra 2017.44907-1 (texlive-most)
local/texlive-music 2017.44885-1 (texlive-most)
local/texlive-pictures 2017.44899-1 (texlive-most)
local/texlive-pstricks 2017.44742-1 (texlive-most)
local/texlive-publishers 2017.44916-1 (texlive-most)
local/texlive-science 2017.44906-1 (texlive-most)

发布此主题后,我们在 Archlinux 论坛上找到了答案。 Lua 语言似乎存在一些内部问题 - package.cpath 无法识别问号,因此必须将 ?.so 更改为 mysql.so。谁能解释为什么会这样?