1 @c -*- coding: utf-8; mode: texinfo; -*-
4 Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
6 When revising a translation, copy the HEAD committish of the
7 version that you are working on. For details, see the Contributors'
8 Guide, node Updating translation committishes..
14 @node Running lilypond
15 @chapter Running @command{lilypond}
17 This chapter details the technicalities of running LilyPond.
21 * Command-line usage::
30 Most users run LilyPond through a GUI; if you have not done so
31 already, please read the @rlearning{Tutorial}. If you use an alternate
32 editor to write lilypond files, see the documentation for that
36 @node Command-line usage
37 @section Command-line usage
39 This section contains extra information about using LilyPond on the
40 command-line. This may be desirable to pass extra options to the
41 program. In addition, there are certain extra @q{helper} programs (such
42 as @code{midi2ly}) which are only available on the command-line.
44 By @q{command-line}, we mean the command line in the operating system.
45 Windows users might be more familiar with the terms @q{DOS shell} or
46 @q{command shell}. MacOS@tie{}X users might be more familiar with the terms
47 @q{terminal} or @q{console}. Some additional setup is required
48 for MacOS@tie{}X users; please see @rweb{MacOS X}.
50 Describing how to use this part of an operating system is outside the
51 scope of this manual; please consult other documentation on this topic
52 if you are unfamiliar with the command-line.
56 * Command line options for lilypond::
57 * Environment variables::
60 @node Invoking lilypond
61 @unnumberedsubsec Invoking @command{lilypond}
63 The @command{lilypond} executable may be called as follows from
67 lilypond [@var{option}]@dots{} @var{file}@dots{}
71 When invoked with a filename that has no extension, the @file{.ly}
72 extension is tried first. To read input from stdin, use a
73 dash (@code{-}) for @var{file}.
75 When @file{filename.ly} is processed it will produce @file{filename.ps}
76 and @file{filename.pdf} as output. Several files can be specified;
77 they will each be processed independently. @footnote{The status of
78 GUILE is not reset after processing a @code{.ly} file, so be careful
79 not to change any system defaults from within Scheme.}
81 If @file{filename.ly} contains more than one @code{\book}
82 block, then the rest of the scores will be output in numbered files,
83 starting with @file{filename-1.pdf}. In addition, the value of
84 @code{output-suffix} will be inserted between the basename and the
85 number. An input file containing
88 #(define output-suffix "violin")
90 #(define output-suffix "cello")
95 will output @var{base}@file{-violin.pdf} and
96 @var{base}@file{-cello-1.pdf}.
99 @node Command line options for lilypond
100 @unnumberedsubsec Command line options for @command{lilypond}
102 @cindex Invoking @command{lilypond}
103 @cindex command line options for @command{lilypond}
104 @cindex options, command line
107 The following options are supported:
111 @item -e,--evaluate=@var{expr}
112 Evaluate the Scheme @var{expr} before parsing any @file{.ly} files.
113 Multiple @code{-e} options may be given, they will be evaluated
116 The expression will be evaluated in the @code{guile-user} module, so
117 if you want to use definitions in @var{expr}, use
120 lilypond -e '(define-public a 42)'
124 on the command-line, and include
127 #(use-modules (guile-user))
131 at the top of the @code{.ly} file.
133 @item -f,--format=@var{format}
134 which formats should be written. Choices for @code{format} are
135 @code{ps}, @code{pdf}, and @code{png}.
137 Example: @code{lilypond -fpng @var{filename}.ly}
141 @item -d,--define-default=@var{var}=@var{val}
142 This sets the internal program option @var{var} to the Scheme value
143 @var{val}. If @var{val} is not supplied, then @var{#t} is used. To
144 switch off an option, @code{no-} may be prefixed to @var{var}, e.g.
146 @cindex point and click, command line
155 -dpoint-and-click='#f'
158 Here are a few interesting options.
160 @cindex help, command line
164 Running @code{lilypond -dhelp} will print all of the @code{-d} options
167 @cindex paper-size, command line
170 This option sets the default paper-size,
172 -dpaper-size=\"letter\"
176 Note that the string must be enclosed in escaped quotes ( @code{\"} ).
177 @c Match " in previous line to help context-sensitive editors
179 @cindex safe, command line
182 Do not trust the @code{.ly} input.
184 When LilyPond formatting is available through a web server, either the
185 @code{--safe} or the @code{--jail} option @b{MUST} be passed. The
186 @code{--safe} option will prevent inline Scheme code from wreaking
193 c4^#(ly:export (ly:gulp-file "/etc/passwd"))
198 The @code{-dsafe} option works by evaluating in-line Scheme
199 expressions in a special safe module. This safe module is derived from
200 GUILE @file{safe-r5rs} module, but adds a number of functions of the
201 LilyPond API. These functions are listed in @file{scm/@/safe@/-lily@/.scm}.
203 In addition, safe mode disallows @code{\include} directives and
204 disables the use of backslashes in @TeX{} strings.
206 In safe mode, it is not possible to import LilyPond variables
209 @code{-dsafe} does @emph{not} detect resource overuse. It is still possible to
210 make the program hang indefinitely, for example by feeding cyclic data
211 structures into the backend. Therefore, if using LilyPond on a
212 publicly accessible webserver, the process should be limited in both
213 CPU and memory usage.
215 The safe mode will prevent many useful LilyPond snippets from being
216 compiled. The @code{--jail} is a more secure alternative, but
217 requires more work to set up.
219 @cindex output format, setting
221 the output format to use for the back-end. Choices for @code{format} are
224 @cindex PostScript output
227 Postscript files include TTF, Type1 and OTF fonts. No subsetting of
228 these fonts is done. When using oriental character sets, this can
233 @cindex Postscript, encapulated
234 @cindex EPS (Encapsulated PostScript)
236 for encapsulated PostScript. This dumps every page (system) as a separate
237 @file{EPS} file, without fonts, and as one collated @file{EPS} file with
238 all pages (systems) including fonts.
240 This mode is used by default by @command{lilypond-book}.
244 @cindex SVG (Scalable Vector Graphics)
246 for SVG (Scalable Vector Graphics).
248 This creates a single SVG file, without embedded fonts, for every
249 page of output. It is recommended to install the Century
250 Schoolbook fonts, included with your LilyPond installation, for
251 optimal rendering. Under UNIX, simply copy these fonts from the
252 LilyPond directory (typically
253 @file{/usr/share/lilypond/VERSION/fonts/otf/}) to
254 @file{~/.fonts/}. The SVG output should be compatible with any
255 SVG editor or user agent.
261 for a dump of the raw, internal Scheme-based drawing commands.
264 do not output a printed score; has the same effect as @code{-dno-print-pages}.
267 Example: @code{lilypond -dbackend=svg @var{filename}.ly}
270 @cindex preview, command line
271 Generate an output file containing the titles and the first system
272 of music. If @code{\bookpart} blocks are used, the titles and
273 first system of every @code{\bookpart} will appear in the output.
274 The @code{ps}, @code{eps}, and @code{svg} backends support this
278 Generate the full pages, the default. @code{-dno-print-pages} is
279 useful in combination with @code{-dpreview}.
286 Show a summary of usage.
288 @item -H,--header=@var{FIELD}
289 Dump a header field to file @file{BASENAME.@var{FIELD}}.
291 @item --include, -I=@var{directory}
292 Add @var{directory} to the search path for input files.
293 @cindex file searching
296 @item -i,--init=@var{file}
297 Set init file to @var{file} (default: @file{init.ly}).
299 @item -o,--output=@var{FILE}
300 Set the default output file to @var{FILE}. The appropriate
301 suffix will be added (e.g. @code{.pdf} for pdf)
303 @cindex PostScript output
308 @cindex Portable Network Graphics (PNG) output
311 Generate pictures of each page, in PNG format. This implies
312 @code{--ps}. The resolution in DPI of the image may be set with
317 @cindex Portable Document Format (PDF) output
320 Generate PDF. This implies @code{--ps}.
324 @item -j,--jail=@var{user},@var{group},@var{jail},@var{dir}
325 Run @command{lilypond} in a chroot jail.
327 The @code{--jail} option provides a more flexible alternative to
328 @code{--safe} when LilyPond formatting is available through a web
329 server or whenever LilyPond executes externally provided
332 The @code{--jail} option works by changing the root of @command{lilypond} to
333 @var{jail} just before starting the actual compilation process. The user
334 and group are then changed to match those provided, and the current
335 directory is changed to @var{dir}. This setup guarantees that it is not
336 possible (at least in theory) to escape from the jail. Note that for
337 @code{--jail} to work @command{lilypond} must be run as root, which is usually
338 accomplished in a safe way using @command{sudo}.
340 Setting up a jail is a slightly delicate matter, as we must be sure that
341 LilyPond is able to find whatever it needs to compile the source
342 @emph{inside the jail}. A typical setup comprises the following items:
345 @item Setting up a separate filesystem
346 A separate filesystem should be created for LilyPond, so that it can be
347 mounted with safe options such as @code{noexec}, @code{nodev}, and
348 @code{nosuid}. In this way, it is impossible to run executables or to
349 write directly to a device from LilyPond. If you do not want to create a
350 separate partition, just create a file of reasonable size and use it to
351 mount a loop device. A separate filesystem also guarantees that LilyPond
352 cannot write more space than it is allowed.
354 @item Setting up a separate user
355 A separate user and group (say, @code{lily}/@code{lily}) with low
356 privileges should be used to run LilyPond inside the jail. There should
357 be a single directory writable by this user, which should be passed in
360 @item Preparing the jail
361 LilyPond needs to read a number of files while running. All these files
362 are to be copied into the jail, under the same path they appear in the
363 real root filesystem. The entire content of the LilyPond installation
364 (e.g., @file{/usr/share/lilypond})
367 If problems arise, the simplest way to trace them down is to run
368 LilyPond using @command{strace}, which will allow you to determine which
371 @item Running LilyPond
372 In a jail mounted with @code{noexec} it is impossible to execute any external
373 program. Therefore LilyPond must be run with a backend that does not
374 require any such program. As we already mentioned, it must be also run
375 with superuser privileges (which, of course, it will lose immediately),
376 possibly using @command{sudo}. It is a good idea to limit the number of
377 seconds of CPU time LilyPond can use (e.g., using @command{ulimit
378 -t}), and, if your operating system supports it, the amount of memory
379 that can be allocated.
384 Show version information.
387 Be verbose: show full paths of all files read, and give timing
391 Show the warranty with which GNU LilyPond comes. (It comes with
392 @strong{NO WARRANTY}!)
395 @node Environment variables
396 @unnumberedsubsec Environment variables
400 @cindex LILYPOND_DATADIR
402 @command{lilypond} recognizes the following environment variables:
404 @item LILYPOND_DATADIR
405 This specifies a directory where locale messages and
406 data files will be looked up by default. The directory should contain
407 subdirectories called @file{ly/}, @file{ps/}, @file{tex/}, etc.
410 This selects the language for the warning messages.
412 @item LILYPOND_GC_YIELD
413 With this variable the memory footprint and performance can be
414 adjusted. It is a percentage tunes memory management behavior. With
415 higher values, the program uses more memory, with smaller values, it
416 uses more CPU time. The default value is @code{70}.
422 @section Error messages
424 @cindex error messages
425 Different error messages can appear while compiling a file:
431 Something looks suspect. If you are requesting something out of the
432 ordinary then you will understand the message, and can ignore it.
433 However, warnings usually indicate that something is wrong with the
438 Something is definitely wrong. The current processing step (parsing,
439 interpreting, or formatting) will be finished, but the next step will
444 Something is definitely wrong, and LilyPond cannot continue. This
445 happens rarely. The most usual cause is misinstalled fonts.
448 @cindex trace, Scheme
451 Errors that occur while executing Scheme code are caught by the Scheme
452 interpreter. If running with the verbose option (@code{-V} or
453 @code{--verbose}) then a call trace of the offending
454 function call is printed.
456 @item Programming error
457 @cindex Programming error
458 There was some internal inconsistency. These error messages are
459 intended to help the programmers and debuggers. Usually, they can be
460 ignored. Sometimes, they come in such big quantities that they obscure
463 @item Aborted (core dumped)
464 @cindex Aborted (core dumped)
465 This signals a serious programming error that caused the program to
466 crash. Such errors are considered critical. If you stumble on one,
470 @cindex errors, message format
471 If warnings and errors can
472 be linked to some part of the input file, then error messages have the
476 @var{filename}:@var{lineno}:@var{columnno}: @var{message}
477 @var{offending input line}
480 A line-break is inserted in the offending line to indicate the column
481 where the error was found. For example,
484 test.ly:2:19: error: not a duration: 5
489 These locations are LilyPond's best guess about where the warning or
490 error occurred, but (by their very nature) warnings and errors occur
491 when something unexpected happens. If you can't see an error in the
492 indicated line of your input file, try checking one or two lines
493 above the indicated position.
495 More information about errors is given in @ref{Common errors}.
499 @section Common errors
501 The error conditions described below occur often, yet the cause
502 is not obvious or easily found. Once seen and understood, they
507 * Music runs off the page::
508 * An extra staff appears::
509 * Apparent error in ../ly/init.ly::
510 * Error message Unbound variable %::
511 * Error message FT_Get_Glyph_Name::
514 @node Music runs off the page
515 @unnumberedsubsec Music runs off the page
517 Music running off the page over the right margin or appearing
518 unduly compressed is almost always due to entering an incorrect
519 duration on a note, causing the final note in a measure to extend
520 over the bar line. It is not invalid if the final note in a
521 measure does not end on the automatically entered bar line, as the
522 note is simply assumed to carry over into the next measure. But
523 if a long sequence of such carry-over measures occurs the music
524 can appear compressed or may flow off the page because automatic
525 line breaks can be inserted only at the end of complete measures,
526 i.e., where all notes end before or at the end of the measure.
528 @warning{An incorrect duration can cause line breaks to be
529 inhibited, leading to a line of highly compressed music or
530 music which flows off the page.}
532 The incorrect duration can be found easily if bar checks are used,
533 see @ruser{Bar and bar number checks}.
535 If you actually intend to have a series of such carry-over measures
536 you will need to insert an invisible bar line where you want the
537 line to break. For details, see @ruser{Bar lines}.
540 @node An extra staff appears
541 @unnumberedsubsec An extra staff appears
543 If contexts are not created explicitly with @code{\new} they will be
544 silently created as soon as a command is encountered which cannot
545 be applied to an existing context. In simple scores the automatic
546 creation of contexts is useful, and most of the examples in the
547 LilyPond manuals take advantage of this simplification. But
548 occasionally the silent creation of contexts can give rise to
549 unexpected new staves or scores. For example, it might be expected
550 that the following code would cause all note heads within the
551 following staff to be colored red, but in fact it results in two
552 staves with the note heads remaining the default black in the lower
555 @lilypond[quote,verbatim,relative=2]
556 \override Staff.NoteHead #'color = #red
560 This is because a @code{Staff} context does not exist when the
561 override is processed, so one is implicitly created and the override
562 is applied to it, but then the @code{\new Staff} command creates
563 another, separate, staff into which the notes are placed. The
564 correct code to color all note heads red is
566 @lilypond[quote,verbatim,relative=2]
568 \override Staff.NoteHead #'color = #red
573 As a second example, if a @code{\relative} command is placed inside
574 a @code{\repeat} command two staves result, the second offset from
575 the first, because the @code{\repeat} command generates two
576 @code{\relative} blocks, which each implicitly create @code{Staff}
577 and @code{Voice} blocks.
579 @lilypond[quote,verbatim]
581 \relative c' { c d e f }
585 The correct way is to reverse the @code{\repeat} and
586 @code{\relative} commands, like this:
588 @lilypond[quote,verbatim]
590 \repeat unfold 2 { c d e f }
595 @node Apparent error in ../ly/init.ly
596 @unnumberedsubsec Apparent error in @code{../ly/init.ly}
598 Various obscure error messages may appear about syntax errors in
599 @code{../ly/init.ly} if the input file is not correctly formed,
600 for example, if it does not contain correctly
601 matched braces or quote signs.
603 The most common error is a missing brace, (@code{@}}), at the end of
604 a @code{score} block. Here the solution is obvious: check the
605 @code{score} block is correctly terminated. The correct structure
606 of an input file is described in @rlearning{How LilyPond input files work}.
607 Using an editor which automatically highlights matching brackets and
608 braces is helpful to avoid such errors.
610 A second common cause is no white space between the last syllable
611 of a lyrics block and the terminating brace, (@code{@}}). Without
612 this separation the brace is taken to be part of the syllable. It
613 is always advisable to ensure there is white space before and after
614 @emph{every} brace. For the importance of this when using lyrics,
615 see @ruser{Lyrics explained}.
617 This error message can also appear if a terminating quote sign,
618 (@code{"}), is omitted. In this case an accompanying error message
619 @c keep "-matching straight in fancy editors
620 should give a line number close to the line in error. The
621 mismatched quote will usually be on the line one or two above.
623 @node Error message Unbound variable %
624 @unnumberedsubsec Error message Unbound variable %
626 This error message will appear at the bottom of the console
627 output or log file together with a @qq{GUILE signalled an error ...}
628 message every time a Scheme routine is called which (invalidly)
629 contains a @emph{LilyPond} rather than a @emph{Scheme} comment.
631 LilyPond comments begin with a percent sign, (@code{%}), and must
632 not be used within Scheme routines. Scheme comments begin with a
633 semi-colon, (@code{;}).
635 @node Error message FT_Get_Glyph_Name
636 @unnumberedsubsec Error message FT_Get_Glyph_Name
638 This error messages appears in the console output or log file if
639 an input file contains a non-ASCII character and was not saved in
640 UTF-8 encoding. For details, see @ruser{Text encoding}.