linusromer / bezierplot

bezierplot is a Lua program that approximates function plots by cubic bézier splines (paths are output in TikZ)
LaTeX Project Public License v1.3c
8 stars 0 forks source link

Incompatibility with recent version of lualatex? #2

Closed fpantigny closed 5 months ago

fpantigny commented 5 months ago

For several years, I have used bezierplot without problem.

With a recent version of lualatex, I have an error with the following MWE:

\documentclass{article}
\usepackage{tikz,bezierplot}
\begin{document}
Test.
\end{document}

I have the following error :

Programs/MiKTeX/tex/lualatex/bezierplot/bezierplot.lua:666: attempt to compare 
number with nil
stack traceback:
    ...l/Programs/MiKTeX/tex/lualatex/bezierplot/bezierplot.lua:666: in function '
bezierplot'
    ...l/Programs/MiKTeX/tex/lualatex/bezierplot/bezierplot.lua:935: in main chunk

    [C]: in function 'require'
    [\directlua]:1: in main chunk.
l.6  \directlua{require("bezierplot")}

I have no error on Overleaf with TeXLive 2023.

linusromer commented 5 months ago

@fpantigny Strange... bezierplot should not be called at all in your MWE. Are you sure that you used this MWE? What version of lualatex throws this error? (Run in a terminal: luatex --credits)

fpantigny commented 5 months ago

I use LuaHBTeX, Version 1.18.0 (MiKTeX 24.3) (format=lualatex 2024.3.17)

Here is the log file that I obtain: log file

I suspect that the problem comes from the last part of the file bezierplot.lua, starting at the line:

if not pcall(debug.getlocal, 4, 1) then...
linusromer commented 5 months ago

@fpantigny I have installed the newest MiKTeX and have checked your MWE. I can confirm that it throws an error. My error message is slightly different:

./bezierplot.lua:619: [string "local x = ...; return -synctex=1"]:1: expe cted near '=' stack traceback: [C]: in function 'assert' ./bezierplot.lua:619: in function 'bezierplot' ./bezierplot.lua:935: in main chunk [C]: in function 'require' [\directlua]:1: in main chunk. l.6 \directlua{require("bezierplot")}

I have checked the install bezierplot.lua file with the current lua-part of lualatex (e.g. C:\Users\xx\AppData\Local\Programs\MiKTeX\tex\lualatex\bezierplot>lualatex --luaonly bezierplot.lua "x^2") and it works. Hence, the error might happen when data is handed over from the lua script to the tex engine (as you suspected). I will read the current lualatex documentations and try to fix the error in the next days.

linusromer commented 5 months ago

The commit https://github.com/linusromer/bezierplot/commit/ab1881eff4fac642ac77b622a4d5f68b14492931 should close this issue.

fpantigny commented 5 months ago

Thanks.