Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lualatex with MikTex: bad argument #2 to 'gsub' #322

Open
BernhardBecker opened this issue Oct 1, 2024 · 2 comments
Open

lualatex with MikTex: bad argument #2 to 'gsub' #322

BernhardBecker opened this issue Oct 1, 2024 · 2 comments

Comments

@BernhardBecker
Copy link

`Module lyluatex Info: Compiling score tmp-ly/504130eafb16e7b481f300c28c1a5064 wi
th LilyPond executable 'c:/Program Files (x86)/LilyPond/usr/bin/lilypond.exe'. o
n input line 21
...Data/Local/Programs/MiKTeX/scripts/lyluatex/lyluatex.lua:119: bad argument #2
to 'gsub' (string/function/table expected)
stack traceback:
[C]: in function 'string.gsub'
...Data/Local/Programs/MiKTeX/scripts/lyluatex/lyluatex.lua:119: in upvalue 'ex
tract_includepaths'
...Data/Local/Programs/MiKTeX/scripts/lyluatex/lyluatex.lua:816: in method 'lil
ypond_cmd'
...Data/Local/Programs/MiKTeX/scripts/lyluatex/lyluatex.lua:1151: in method 'ru
n_lilypond'
...Data/Local/Programs/MiKTeX/scripts/lyluatex/lyluatex.lua:1115: in method 'pr
ocess'
[\directlua]:1: in main chunk.
\ly@compilescore ...directlua {ly.score:process()}

l.21 \end{lilypond}`

A full description is written on
https://tex.stackexchange.com/questions/727209/lylualatex-lilypond-error-when-compiling-with-miktex

@BrianInGermany
Copy link

BrianInGermany commented Dec 29, 2024

I solved this one with ChatGPT:

In the function extract_includepaths, you need to replace the block starting at local cfd with the following code:

    local cfd = Score.currfiledir or ""
if cfd == "" then
    warn("Score.currfiledir is empty; using default './'")
    cfd = "./"
end
if lib.tex_engine.dist == 'MiKTeX' then
    cfd = cfd:gsub('^$', '.\\')
else
    cfd = cfd:gsub('^$', './')
end

I found this after printing the contents of those two arguments. The currentfiledir one was null. For me this solved it. In the picture, the green commented code is the stuff you need to replace.
image

@BrianInGermany
Copy link

@jperon First of all thank you for this amazing resource! Its just what I need to for my new songbook.
I believe this bug is only relevant to miktex, but it would be great (if you confirm it was the cause) if the solution could be added to the repo.

Should I attempt to make a pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants