jperon / lyluatex

Alternative à lilypond-book pour lualatex
MIT License
56 stars 11 forks source link

The score doesn't contain any music #299

Closed szollbrecht closed 1 year ago

szollbrecht commented 1 year ago

Hi, I'm trying to set up lyluatex with miktex and lilypond 2.19.83 on windows 11 (I've also tried the current version 2.22.2 of lilypond, but downgraded to a version mentioned in the documentation).

So far I've overcome an issue where lilypond could not be started when installed in a directory including spaces. I removed it and re-installed it in a different location. The program option is not needed because I've added lilypond to the PATH. The currfile package was missing, so I installed it.

I have this little example in a test.tex:

\documentclass{scrreprt}
\usepackage[debug,nofragment]{lyluatex}

\begin{document}
  \begin{lilypond}
  \relative c' { c d e f g a b c }
  \end{lilypond}
\end{document}

I run this command: lualatex.exe --shell-escape test.tex and see this in the logs:

Module lyluatex Info: Compiling score tmp-ly/9067f8a68673f005db5fe127426cccb3 wi
th LilyPond executable 'lilypond'. on input line 8
Module lyluatex Info: GNU LilyPond 2.19.83
 on input line 8
Module lyluatex Info: Command:
(lyluatex)            ""lilypond" -E -dno-point-and-click -djob-count=2 -dno-del
ete-intermediate-files -I "C:\workspace\latex\lylua/" -I "C:\workspace\latex\ly
lua/" -o "tmp-ly/9067f8a68673f005db5fe127426cccb3" tmp-ly/9067f8a68673f005db5fe
127426cccb3.ly 2>&1" on input line 8
Module lyluatex Info: Command:
(lyluatex)            ""lilypond" -E -dno-point-and-click -djob-count=2 -dno-del
ete-intermediate-files -I "C:\workspace\latex\lylua/" -I "C:\workspace\latex\ly
lua/" -o "tmp-ly/9067f8a68673f005db5fe127426cccb3" tmp-ly/9067f8a68673f005db5fe
127426cccb3.ly 2>&1" on input line 8

Module lyluatex Warning: The score doesn't contain any music:
(lyluatex)               this will probably cause bad output. on input line 8
...ppData/Local/Programs/MiKTeX/tex/latex/base/ltluatex.lua:110: 
Module lyluatex Error: 
(lyluatex)             LilyPond failed to compile the score.
(lyluatex)             Please check the log file
(lyluatex)             and the generated LilyPond code in
(lyluatex)             tmp-ly/9067f8a68673f005db5fe127426cccb3.log
(lyluatex)             tmp-ly/9067f8a68673f005db5fe127426cccb3.ly
(lyluatex)             
(lyluatex)             on input line 8

stack traceback:
    [C]: in function 'error'
    ...ppData/Local/Programs/MiKTeX/tex/latex/base/ltluatex.lua:110: in function <.
..ppData/Local/Programs/MiKTeX/tex/latex/base/ltluatex.lua:109>
    (...tail calls...)
    ./lyluatex.lua:550: in method 'check_compilation'
    ./lyluatex.lua:1194: in method 'write_latex'
    ./lyluatex.lua:1118: in method 'process'
    [\directlua]:1: in main chunk.
\ly@compilescore ...directlua {ly.score:process()}

l.8   \end{lilypond}

When I check the tmp-ly folder, the .ly file has been generated (looks good to me) 76a3e2f5cb3b8de09f224c7fb34a4449.txt

The corresponding log file unfortunately only says The syntax for the file name, directory name, or volume label is incorrect.

I'm grateful for any help :)

jperon commented 1 year ago

There shouldn’t be any problem with 2.22 (and even with 2.23 if using latest release of lyluatex).

The produced .ly is good.

The problem comes from the fact I didn’t ever succeed to have lualatex on MiKTeX find lilypond correctly. Please try with the program option set; if it doesn’t work, the only workaround I know for now (till I find time to find a fix for this problem) would be to use TeXLive.

szollbrecht commented 1 year ago

Thanks for the quick reply!

You're right, it's just working fine with TeXLive.

Still I kept debugging a bit and found out that it works with miktex when I remove line 809 (without setting the program option btw):

if lib.tex_engine.dist == 'MiKTeX' then cmd = '"'..cmd..'"' end

Strangely enough, it only works in debug mode. When I remove debug=true it gets stuck compiling (at least the last log entry says so).

So just guessing I commented out the if condition in lines 791 and 797. I don't understand what you're doing there to input, but it seems to help ;)

-- if self.debug then
    local f = io.open(self.output..'.ly', 'w')
    f:write(self.complete_ly_code)
    f:close()
    input = self.output..".ly 2>&1"
    mode = 'r'
-- end

That keeps me with a warning I'm not sure if it can be a problem:

Module lyluatex Warning: gs couldn't be launched; there could be rounding error s. on input line 9

Let me know what you think.

jperon commented 1 year ago

The line you mention is what remains after one of my attempts to fix the problems with MiKTeX…

The warning about gs isn’t such a problem, it just means that the width of your scores won’t be so exact as with gs.

My main problem with MiKTeX is that it is used on Windows, while I work on Linux ; so, to debug it, I’d need to set a virtual machine, which is time consuming… So if you find a solution to this problem, don’t fear submitting a pull request. Otherwise, I still plan to look at this, but it isn’t on my priority list (as TeXLive is always a possible workaround).

szollbrecht commented 1 year ago

I see, thanks. I will check again, too, when I find the time :)

szollbrecht commented 1 year ago

I'll close this for now since we merged #300 If there's another or the same issue in a higher version of lyluatex, we can reopen or open a new issue.