"kpairs" error on examples Markdown file
celtic-coder opened this issue · 5 comments
Hi Didier (@Omikhleia),
I installed the SILE Typesetter and "markdown.sile" on Ubuntu as noted in the Discussions. I cloned the repo and then tried to run SILE on the "introduction.md" file in the "examples" folder:
sile --use inputters.markdown --use packages.autodoc introduction.md
This gave the following error:
The text of the error is:
SILE v0.14.9 (Lua 5.2)
! Unexpected Lua error
error summary:
Processing at: introduction.md: in <snippet>:
[[# IntroductionThis collection of modules for the [SILE](https://github.com/sile-typesetter/sile) t]]
Using code at: /usr/share/sile/packages/math/texlike.lua:188: attempt to call field 'kpairs' (a nil value)
Run with --traceback for more detailed trace leading up to errors.
Running the --traceback
gives the following extended output:
SILE v0.14.9 (Lua 5.2)
! Unexpected Lua error
stack traceback:
/usr/share/sile/packages/math/texlike.lua:188: in function 'fold_pairs'
/usr/share/sile/packages/math/texlike.lua:256: in function 'compileToMathML_aux'
/usr/share/sile/packages/math/texlike.lua:398: in function 'compileToMathML'
/usr/share/sile/packages/math/texlike.lua:420: in main chunk
[C]: in function 'require'
/usr/share/sile/packages/math/init.lua:10: in function 'init'
/usr/share/lua/5.2/pl/class.lua:38: in function 'call_ctor'
/usr/share/lua/5.2/pl/class.lua:171: in function 'pack'
/usr/share/sile/classes/base.lua:145: in function 'loadPackage'
...
/home/new/.luarocks/share/lua/5.2/sile/classes/markdown.lua:7: in function 'init'
/usr/share/lua/5.2/pl/class.lua:38: in function 'call_ctor'
/usr/share/lua/5.2/pl/class.lua:171: in function 'constructor'
/usr/share/sile/inputters/base.lua:31: in function 'classInit'
/usr/share/sile/inputters/base.lua:40: in function 'requireClass'
/usr/share/sile/inputters/base.lua:48: in function 'process'
/usr/share/sile/core/sile.lua:298: in function 'processString'
/usr/share/sile/core/sile.lua:330: in function </usr/share/sile/core/sile.lua:303>
(...tail calls...)
[C]: in function 'xpcall'
/usr/bin/sile:127: in main chunk
[C]: in ?
error summary:
Processing at: introduction.md: in <snippet>:
[[# IntroductionThis collection of modules for the [SILE](https://github.com/sile-typesetter/sile) t]]
Using code at: /usr/share/sile/packages/math/texlike.lua:188: attempt to call field 'kpairs' (a nil value)
new@DESKTOP-SNF8BOK:~/GitHub/Omikhleia/markdown.sile/examples$
As noted in the Discussion, I installed everything locally, which is why there is a reference to /home/new/.luarocks/share/lua/5.2/sile/classes/markdown.lua:7: in function 'init'
in the above output.
Running cat /home/new/.luarocks/share/lua/5.2/sile/classes/markdown.lua
gives:
local book = require("classes.book")
local class = pl.class(book)
class._name = "markdown"
function class:_init (options)
book._init(self, options)
self:loadPackage("markdown")
return self
end
return class
This looks like your classes/markdown.lua file:
I do not know how classes or packages work in Lua, but I would have expected that the local inputters/markdown.lua would have been part of that trace, since it is specified in the --use
on the command line.
The only reference to "inputters" in the traceback are the following lines:
/usr/share/sile/inputters/base.lua:40: in function 'requireClass'
/usr/share/sile/inputters/base.lua:31: in function 'classInit'
/usr/share/sile/inputters/base.lua:48: in function 'process'
Is this expected? Further, when I do a locate "markdown.lua"
, the first three entries are:
/home/new/.luarocks/share/lua/5.2/sile/classes/markdown.lua
/home/new/.luarocks/share/lua/5.2/sile/inputters/markdown.lua
/home/new/.luarocks/share/lua/5.2/sile/lunamark/reader/markdown.lua
These are the expected "local" entries. Is there possibly an issue with the PATH such that the "classes" is being picked up ahead of the "inputters"? Or have I gone down the wrong rabbit trail completely?
In any case, your assistance would be appreciated!
Kind Regards,
Liam
I failed to reproduce the issue: sile --use inputters.markdown --use packages.autodoc examples/introduction.md
worked fine on my setup.
/usr/share/sile/packages/math/texlike.lua:188
is in SILE's math package, and the error seems to be on the call to pl.utils.kpairs
. That's a function from the Penlight library, that was added to it about 1 year ago (in Penlight 1.13.0 lunarmodules/Penlight@4ea8dae), but your log says it's nil, so my best guess would be that your SILE setup for some reason is using an older version (either a SILE installation problem, or another version shadowing the one normally used by SILE?).
To confirm this, can you try sile -e 'print("Penlight ",pl.utils._VERSION)'
and check the version of Penlight's utils version it displays? I got 1.13.1:
SILE v0.14.9 (Lua 5.4)
Penlight 1.13.1
If it does report an older version, then perhaps check where and how Penlight is located on your system.
You could also check how your SILE setup behaves with maths in a simple SIL file:
\begin{document}
\use[module=packages.math]
\math[mode=display]{(\frac{a}{b})}
\end{document}
Depending on the findings, you might want to report the issue to SILE (perhaps the Ubuntu build has an issue?)
I am not sure what to do with the rest of your message (It seems a normal stack to me at this point, likely after the markdown inputter converted the file into a SILE AST which is then being processed, but the inputter is no longer in scope then)
Hi Didier (@Omikhleia),
You are correct. The Penlight version is older:
SILE v0.14.9 (Lua 5.2)
Penlight 1.12.0
The Penlight CHANGELOG shows that "utils.kpairs" was indeed installed in version 1.13.0 (2022-Jul-22). When I installed SILE, the output contained the following lines (confirming the version of Penlight):
Selecting previously unselected package lua-penlight:amd64.
Preparing to unpack .../09-lua-penlight_1.12.0-2ppa1~ubuntu22.04_amd64.deb ...
Unpacking lua-penlight:amd64 (1.12.0-2ppa1~ubuntu22.04) ...
I therefore used Luarocks to install the latest version of Penlight (sudo luarocks install penlight
) and I repeated the test of the Penlight version in SILE:
SILE v0.14.9 (Lua 5.2)
Penlight 1.13.1
When I re-ran the previous SILE command (sile --use inputters.markdown --use packages.autodoc introduction.md
), I got the following output:
SILE v0.14.9 (Lua 5.2)
[1] [2] </usr/share/sile/core/languages.lua:75> as xml
<...arocks/share/lua/5.2/sile/packages/markdown/commands.lua:502> as sil
<...arocks/share/lua/5.2/sile/packages/markdown/commands.lua:502> as sil
<...arocks/share/lua/5.2/sile/packages/markdown/commands.lua:502> as sil
! Font family 'Hack' not available, falling back to 'Gentium Plus' at in "luarocks --lua-ver…" near introduction.md:0:0: in \markdown:internal:codeblock[class="bash"]
[3]
! Warning: table of contents has changed, please rerun SILE to update it.
Now, at least, there is a correct PDF file created even though the table of contents is blank. So, this is progress! I was going to try to implement your math sample, but I am having problems installing the correct math font in Ubuntu in order to make it work. I'll come back to this later.
In any case, a PDF is being output. So, thanks Didier for your assistance with this issue!
Kind Regards,
Liam
Preparing to unpack .../09-lua-penlight_1.12.0-2ppa1~ubuntu22.04_amd64.deb
This should maybe be notified to SILE or the Ubuntu packager.
@alerque might perhaps know who to ping for an update of lua-penlight on the Ubuntu PPA ?
Handled by SILE sile-typesetter/sile#1825, so closing here
Hi Didier (@Omikhleia),
You beat me to it! 👍 Given that I am able to create PDF files without the "kpairs" error and that Caleb (@alerque) has gone through the steps required to update the PPA as noted in sile-typesetter/sile#1825, I was going to close this issue.
So, thanks for taking care of this!
Kind Regards,
Liam