5.4 Troubleshooting

Sooner or later, you will write a file that LilyPond cannot compile. The messages that LilyPond gives may help you find the error, but in many cases you need to do some investigation to determine the source of the problem.

The most powerful tools for this purpose are the single line comment (indicated by %) and the block comment (indicated by %{…%}). If you don’t know where a problem is, start commenting out huge portions of your input file. After you comment out a section, try compiling the file again. If it works, then the problem must exist in the portion you just commented. If it doesn’t work, then keep on commenting out material until you have something that works.

In an extreme case, you might end up with only

\score {
    % \melody
    % \harmony
    % \bass

(in other words, a file without any music)

If that happens, don’t give up. Uncomment a bit – say, the bass part – and see if it works. If it doesn’t work, then comment out all of the bass music (but leave \bass in the \score uncommented.

bass = \relative {
  c'4 c c c
  d d d d

Now start slowly uncommenting more and more of the bass part until you find the problem line.

Another very useful debugging technique is constructing Tiny examples.

LilyPond Application Usage v2.25.16 (development-branch).