Running lilypond with .unixCmd or .systemCmd?

Hey! I’m running Supercollider 3.13.0 and I’m trying to render pdf-files with lilypond from Supercollider by running unix-commands with the unixCmd or systemCmd methods.
I got it working by using the .runInTerminal method with something like “cd directorypath; lilypond --pdf filename.ly”, but it opens a terminalwindow which I have to close every time I want a new output from lilypond which I wanna find a way around and make it do it in the background.
I tried .systemCmd and .unixCmd with the similar “cd directorypath; lilypond --pdf filename.ly” but it didn’t run lilypond. What is going on here, and how can I get what I want?

Martin

Maybe try the entire path to the lilypond executable.

1 Like

Tried it, still gives me the same result!

Someone can correct me, but I don’t think you can change directory, so you need to have the full path of lilypond and the full path of the filename:

full_path_to_lilypond --pdf full/path/to/filename.ly

This is at least how I do it in my code.

Sam

1 Like

Ok so I tried a few things: “cd” does work, it allows me to create svg-files by cd’ing into the directory, then doing full_path_to_lilypond as you suggested but on only the filename, making it work, but only for svg-files, which is a bit weird?
I also tried writing fullPathToFile with the same results letting me write svgs but not pdfs. Any ideas?

In UNIXy systems, the one-liner for this would be:

cd directorypath && lilypond --pdf filename.ly

If directorypath is the location of the ly file, then the path to the lilypond executable should already be in the $PATH system variable (which can be set in your shell init script – which depends on the shell being used but is often ~/.bashrc IIRC).

Otherwise, you could do cd pathToLilypond && lilypond --pdf fullPathToFile.ly which, since you’re generating the command in SC, should be straightforward.

In Windows, I don’t recall the equivalent for &&.

hjh

1 Like

On my machine, the SC unix shell doesn’t know the system PATH. Thus the full path to things.

1 Like

This is weird. I tested it on my side, and the issue only appears with Lilypond. I am curious about the outcome of this thread.

1 Like

I tried ´´cd pathToLilypond && lilypond --pdf fullPathToFile.ly´´ but lilypond wouldn’t run. The only variant that seems to work with .unixCmd or .systemCmd is fullPathToLilypond --svg fullPathToFile but only with doing --svg.
When I use --pdf I can see it doing something, as it takes like 1 second to get the return in the post-window. Ideas?
Not sure if I understood your comment about the $PATH variable, as I’m not totally familiar with using it. Is there something I should edit to maybe get it working?

Pending a solution to this issue, and depending on what your purpose is, I would recommend writing scores on the fly – and not only – with the software INscore which uses the Guido Music Notation.
Y.

I bet it is saving the file in a funny place. Look at the lilypond help:

lilypond -h

You can specify an output file our folder. Specify the folder where your .ly file is and I bet it will show up in that folder:

-o, --output=FILE                write output to FILE (suffix will be added)
                                     or to FOLDER, in which case the file name
                                     will be taken from the input file.

The thing with the PATH is this: your terminal has a PATH. It knows where the lilypond executable is even though it isn’t is the same directory that you are in. However, the shell in SC that unixCmd uses doesn’t know this PATH, so you need to provide full path names to things.

Sam

nope! I tried! this does not work (at least for me) either!
for the record:

$lilypond --version 
GNU LilyPond 2.25.13 (running Guile 2.2)

This is a lilypond problem. It doesn’t work if you aren’t in the same directory as the file you are compiling…which is not how this is supposed to work. So the correct place for this question is the lilypond forum because you are doing this correctly. Maybe an older version of lilypond works correctly. I tried with the current version.

Sam

This works here:

("lilypond -o " ++ "~/desktop/music.pdf".standardizePath ++ " " ++ "~/desktop/music.ly".standardizePath).unixCmd

After exiting the Lilypond process, you can use the unixCmd action function to open the PDF. It works just fine and can be practical.