1 @c -*- coding: utf-8; mode: texinfo; -*-
3 @chapter Running LilyPond
5 This chapter details the technicalities of running LilyPond.
11 * Updating files with convert-ly::
16 @node Invoking lilypond
17 @section Invoking lilypond
18 @cindex Invoking LilyPond
19 @cindex command line options
20 @cindex options, command line
24 The @code{lilypond} executable may be called as follows from the command line.
27 lilypond [@var{option}]@dots{} @var{file}@dots{}
31 When invoked with a filename that has no extension, the @file{.ly}
32 extension is tried first. To read input from stdin, use a
33 dash (@code{-}) for @var{file}.
35 When @file{filename.ly} is processed it will produce
36 @file{filename.tex} as output (or @file{filename.ps} for PostScript
37 output). If @file{filename.ly} contains more than one @code{\score}
38 block, then the rest of the scores will be output in numbered files,
39 starting with @file{filename-1.tex}. Several files can be specified;
40 they will each be processed independently. @footnote{The status of
41 GUILE is not reset after processing a @code{.ly} file, so be careful
42 not to change any system defaults from within Scheme.}
45 @section Command line options
47 The following options are supported:
51 @item -e,--evaluate=@var{expr}
52 Evaluate the Scheme @var{expr} before parsing any @file{.ly} files.
53 Multiple @code{-e} options may be given, they will be evaluated
56 @item -f,--format=@var{format}
57 which formats should be written. Choices are @code{svg}, @code{ps},
58 @code{pdf}, @code{png}, @code{tex}, @code{dvi}.
60 @item -b,--backend=@var{format}
61 the output format to use for the back-end. Choices are
64 for @TeX{} output, to be processed with La@TeX{}. If present, the file
65 @file{file.textmetrics} is read to determine text extents.
67 dump text strings to @file{.texstr} file, which can be run through
68 (La)@TeX{}, resulting in a @code{.textmetrics} file, which contains the
69 extents of strings of text.
72 @cindex PostScript output
74 Postscript files include TTF, Type1 and OTF fonts. No subsetting of
75 these fonts is done. When using oriental character sets, this can
79 for encapsulated PostScript. This dumps every page (system) as a separate
80 @file{EPS} file, without fonts, and as one collated @file{EPS} file with
81 all pages (systems) including fonts.
83 This mode is used by default by lilypond-book.
86 for SVG (Scalable Vector Graphics). This dumps every page as a separate
87 @file{SVG} file, with embedded fonts.
88 @cindex SVG (Scalable Vector Graphics)
89 You need a SVG viewer which supports embedded fonts, or a SVG
90 viewer which is able to replace the embedded fonts with OTF fonts.
91 Under Unix, you may use @uref{http://www.inkscape.org,Inkscape}
92 (version 0.42 or later), after copying the OTF fonts in directory
93 @file{PATH/TO/share/lilypond/VERSION/fonts/otf/} to @file{~/.fonts/}.
95 for a dump of the raw, internal Scheme-based drawing commands.
99 @cindex output format, setting
101 @item -d,--define-default=@var{var}=@var{val}
102 This sets the internal program option @var{var} to the Scheme value
103 @var{val}. If @var{val} is not supplied, then @var{#t} is used. To
104 switch off an option, @code{no-} may be prefixed to @var{var}, eg.
112 -dpoint-and-click='#f'
115 @cindex point and click
117 Setting the @code{help} option will print a summary of the options
121 Show a summary of usage.
123 @item --include, -I=@var{directory}
124 Add @var{directory} to the search path for input files.
125 @cindex file searching
128 @item -i,--init=@var{file}
129 Set init file to @var{file} (default: @file{init.ly}).
131 @item -o,--output=@var{FILE}
132 Set the default output file to @var{FILE}. The appropriate
133 suffix will be added (ie @code{.pdf} for pdf, @code{.tex}
140 Generate DVI files. In this case, the @TeX{} backend should be
141 specified, i.e., @code{-b tex}.
144 Generate pictures of each page, in PNG format. This implies
145 @code{--ps}. The resolution in DPI of the image may be set with
151 Generate PDF. This implies @code{--ps}.
154 Generate an output file containing the titles and the first system
157 Do not generate the full pages. Useful in combination with
161 Do not trust the @code{.ly} input.
163 When LilyPond formatting is available through a web server, either the
164 @code{--safe} or the @code{--jail} option @b{MUST} be passed. The
165 @code{--safe} option will prevent inline Scheme code from wreaking
168 When LilyPond formatting is available through a web server, the
169 @code{--safe} @b{MUST} be passed. This will prevent inline Scheme
170 code from wreaking havoc, for example
176 c4^#(ly:export (ly:gulp-file "/etc/passwd"))
181 The @code{--safe} option works by evaluating in-line Scheme
182 expressions in a special safe module. This safe module is derived from
183 GUILE @file{safe-r5rs} module, but adds a number of functions of the
184 LilyPond API. These functions are listed in @file{scm/@/safe@/-lily@/.scm}.
186 In addition, @code{--safe} disallows @code{\include} directives and
187 disables the use of backslashes in @TeX{} strings.
189 In @code{--safe} mode, it is not possible to import LilyPond variables
192 @code{--safe} does @emph{not} detect resource overuse. It is still
193 possible to make the program hang indefinitely, for example by feeding
194 cyclic data structures into the backend. Therefore, if using LilyPond
195 on a publicly accessible webserver, the process should be limited in
196 both CPU and memory usage.
198 Note that @code{--safe} will prevent many useful LilyPond snippets from
199 being compiled. For a softer but secure alternative you can use the
200 @code{--jail} option.
203 @item -j,--jail=@var{user},@var{group},@var{jail},@var{dir}
204 Run LilyPond in a chroot jail.
206 The @code{--jail} option provides a more flexible alternative to
207 @code{--safe} when LilyPond formatting is available through a web
208 server or whenever LilyPond executes externally provided
211 The @code{--jail} option works by changing the root of LilyPond to
212 @var{jail} just before starting the actual compilation process. The user
213 and group are then changed to match those provided, and the current
214 directory is changed to @var{dir}. This setup guarantees that it is not
215 possible (at least in theory) to escape from the jail. Note that for
216 @code{--jail} to work LilyPond must be run as root, which is usually
217 accomplished in a safe way using @command{sudo}.
219 Setting up a jail is a slightly delicate matter, as we must be sure that
220 LilyPond is able to find whatever it needs to compile the source
221 @emph{inside the jail}. A typical setup comprises the following items:
224 @item Setting up a separate filesystem
225 A separate filesystem should be created for LilyPond, so that it can be
226 mounted with safe options such as @code{noexec}, @code{nodev}, and
227 @code{nosuid}. In this way, it is impossible to run executables or to
228 write directly to a device from LilyPond. If you do not want to create a
229 separate partition, just create a file of reasonable size and use it to
230 mount a loop device. A separate filesystem also guarantees that LilyPond
231 cannot write more space than it is allowed.
233 @item Setting up a separate user
234 A separate user and group (say, @samp{lily}/@samp{lily}) with low
235 privileges should be used to run LilyPond inside the jail. There should
236 be a single directory writable by this user, which should be passed in
239 @item Preparing the jail
240 LilyPond needs to read a number of files while running. All these files
241 are to be copied into the jail, under the same path they apper in the
242 real root filesystem. The entire content of the LilyPond installation
243 (e.g., @file{/usr/share/lilypond})
246 If problems arise, the simplest way to trace them down is to run
247 LilyPond using @command{strace}, which will allow you to determine which
250 @item Running LilyPond
251 In a jail mounted with @code{noexec} it is impossible to execute any external
252 program. Therefore LilyPond must be run with a backend that does not
253 require any such program. As we already mentioned, it must be also run
254 with superuser privileges (which, of course, it will lose immediately),
255 possibly using @command{sudo}. It is a good idea to limit the number of
256 seconds of CPU time LilyPond can use (e.g., using @command{ulimit
257 -t}), and, if your operating system supports it, the amount of memory
258 that can be allocated.
263 Show version information.
266 Be verbose: show full paths of all files read, and give timing
270 Show the warranty with which GNU LilyPond comes. (It comes with
271 @strong{NO WARRANTY}!)
275 @section Environment variables
279 @cindex LILYPONDPREFIX
281 @code{Lilypond} recognizes the following environment variables:
284 This specifies a directory where locale messages and
285 data files will be looked up by default. The directory should contain
286 subdirectories called @file{ly/}, @file{ps/}, @file{tex/}, etc.
289 This selects the language for the warning messages.
291 @item LILYPOND_GC_YIELD
292 With this variable the memory footprint and performance can be
293 adjusted. It is a percentage tunes memory management behavior. With
294 higher values, the program uses more memory, with smaller values, it
295 uses more CPU time. The default value is @code{70}.
301 @section Error messages
303 @cindex error messages
304 Different error messages can appear while compiling a file:
310 Something looks suspect. If you are requesting something out of the
311 ordinary then you will understand the message, and can ignore it.
312 However, warnings usually indicate that something is wrong with the
316 Something is definitely wrong. The current processing step (parsing,
317 interpreting, or formatting) will be finished, but the next step will
323 Something is definitely wrong, and LilyPond cannot continue. This
324 happens rarely. The most usual cause is misinstalled fonts.
326 @cindex trace, Scheme
330 Errors that occur while executing Scheme code are caught by the Scheme
331 interpreter. If running with the verbose option (@code{-V} or
332 @code{--verbose}) then a call trace of the offending
333 function call is printed.
335 @cindex Programming error
336 @item Programming error
337 There was some internal inconsistency. These error messages are
338 intended to help the programmers and debuggers. Usually, they can be
339 ignored. Sometimes, they come in such big quantities that they obscure
340 other output. In this case, file a bug-report.
342 @item Aborted (core dumped)
343 This signals a serious programming error that caused the program to
344 crash. Such errors are considered critical. If you stumble on one,
350 @cindex errors, message format
351 If warnings and errors can
352 be linked to some part of the input file, then error messages have the
356 @var{filename}:@var{lineno}:@var{columnno}: @var{message}
357 @var{offending input line}
360 A line-break is inserted in the offending line to indicate the column
361 where the error was found. For example,
364 test.ly:2:19: error: not a duration: 5:
369 These locations are LilyPond's best guess about where the warning or
370 error occured, but (by their very nature) warnings and errors occur
371 when something unexpected happens. If you can't see an error in the
372 indicated line of your input file, try checking one or two lines
373 above the indicated position.
376 @node Updating files with convert-ly
377 @section Updating with @command{convert-ly}
379 @cindex Updating a LilyPond file
380 @cindex @code{convert-ly}
382 The LilyPond input syntax is routinely changed to simplify it or improve
383 it in different ways. As a side effect of this, the LilyPond interpreter
384 often is no longer compatible with older input files. To remedy this,
385 the program @command{convert-ly} can be used to deal with most of the
386 syntax changes between LilyPond versions.
388 It uses @code{\version} statements in the input files to detect the
389 old version number. In most cases, to upgrade your input file it is
390 sufficient to run@footnote{MacOS X users may execute this command
391 under the menu entry @samp{Compile > Update syntax}.}
394 convert-ly -e myfile.ly
397 If there are no changes to myfile.ly and file called myfile.ly.NEW
398 is created, then myfile.ly is already updated.
400 @command{convert-ly} always converts up to the last syntax change handled by
401 it. This means that the @code{\version} number left in the file is
402 usually lower than the version of @command{convert-ly} itself.
404 To upgrade LilyPond fragments in texinfo files, use
407 convert-ly --from=... --to=... --no-version *.itely
410 To upgrade many files at once, combine @code{convert-ly} with
411 standard unix commands. This example will upgrade all @code{.ly}
412 files in the current directory
415 for f in *.ly; do convert-ly -e $f; done;
418 In general, the program is invoked as follows:
421 convert-ly [@var{option}]@dots{} @var{file}@dots{}
425 The following options can be given:
429 Do an inline edit of the input file. Overrides @code{--output}.
431 @item -f,--from=@var{from-patchlevel}
432 Set the version to convert from. If this is not set, @command{convert-ly}
433 will guess this, on the basis of @code{\version} strings in the file.
435 @item -n,--no-version
436 Normally, @command{convert-ly} adds a @code{\version} indicator
437 to the output. Specifying this option suppresses this.
439 @item -s, --show-rules
440 Show all known conversions and exit.
442 @item --to=@var{to-patchlevel}
443 Set the goal version of the conversion. It defaults to the latest
453 Not all language changes are handled. Only one output option can be
457 @c We might want to make this a completely new section, along with more
458 @c info about how to upgrade old input files. -gp
461 Copy and paste from CVS, last updated
464 http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/lilypond/lily-bugs/bugs/convert-ly.txt?rev=HEAD&content-type=text/plain
468 There are a few things that the convert-ly cannot handle. Here's a list of limitations
469 that the community has complained about.
471 This bug report structure has been chosen because convert-ly has a structure that doesn't
472 allow to smoothly implement all needed changes. Thus this is just a wishlist, placed
476 Doesn't always convert figured bass correctly, specifically things like {< >}. Mats' comment on working around this:
477 To be able to run convert-ly
478 on it, I first replaced all occurencies of '{<' to some dummy like '{#'
479 and similarly I replaced '>}' with '&}'. After the conversion, I could
480 then change back from '{ #' to '{ <' and from '& }' to '> }'.
481 Doesn't convert all text markup correctly. In the old markup syntax,
482 it was possible to group a number of markup commands together within parentheses, e.g.
483 -#'((bold italic) "string")
484 This will incorrectly be converted into
485 -\markup{{\bold italic} "string"}
486 instead of the correct
487 -\markup{\bold \italic "string"}
489 Doesn't handle \partcombine
490 Doesn't do \addlyrics => \lyricsto, this breaks some scores with multiple stanzas.
492 \magnify isn't changed to \fontsize.
493 - \magnify #m => \fontsize #f, where f = 6ln(m)/ln(2)
494 remove-tag isn't changed.
495 - \applyMusic #(remove-tag '. . .) => \keepWithTag #'. . .
496 first-page-number isn't changed.
497 - first-page-number no => printfirst-page-number = ##f
498 Line breaks in header strings aren't converted.
499 - \\\\ as line break in \header strings => \markup \center-align <
500 "First Line" "Second Line" >
501 Crescendo and decrescendo terminators aren't converted.
505 \turnOff (used in \set Staff.VoltaBracket = \turnOff) is not properly converted.
507 \markup{ \center-align <{ ... }> } should be converted to:
508 \markup{ \center-align {\line { ... }} }
509 but now, \line is missing.
511 Special LaTeX characters such as $~$ in text are not converted to UTF8.
517 @section Reporting bugs
520 @cindex reporting bugs
522 If you have input that results in a crash or an erroneous output, then
523 that is a bug. We try to respond to bug-reports promptly, and fix them as
524 soon as possible. Help us by sending a defective input file, so we can
525 reproduce the problem. Make it small, so we can easily debug the
526 problem. Don't forget to tell which version of LilyPond you use! Send
530 @uref{http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs}
534 @c the bug database is not up to date enough.
536 When you've found a bug, have a look at our
537 @uref{http://@/lilypond@/.org/@/doc/@/v2.5/@/bugs/,bug database} to see if
538 it has already been reported. You could also try to do a few searches
539 on the mailing list for the bug. Sometimes the bug will have already
540 been reported and a fix or workaround is already known.
543 Here is an example of a good bug report:
546 It seems that placement of accidentals is broken. In the
547 following example, the accidental touches the note head.
549 Using Mac OSX 10.3.7, fink package lilypond-devel
560 \override Accidental #'extra-offset = #'(1.0 . 0)
566 @section Editor support
571 @cindex modes, editor
572 @cindex syntax coloring
573 @cindex coloring, syntax
575 There is support from different editors for LilyPond.
579 Emacs has a @file{lilypond-mode}, which provides keyword
580 autocompletion, indentation, LilyPond specific parenthesis matching
581 and syntax coloring, handy compile short-cuts and reading LilyPond
582 manuals using Info. If @file{lilypond-mode} is not installed on your
583 platform, then read the
585 @uref{source/Documentation/topdocs/INSTALL.html,installation instructions}.
588 installation instructions.
593 For @uref{http://@/www@/.vim@/.org,VIM}, a @file{vimrc} is supplied, along
594 with syntax coloring tools. For more information, refer to the
596 @uref{source/Documentation/topdocs/INSTALL.html,installation instructions}.
599 installation instructions.
605 The @uref{http://@/www@/.jedit@/.org@/,jEdit} editor has a LilyPond plugin.
606 This plugin includes a DVI viewer, integrated help and viewing via
607 GhostScript. It can be installed by doing @key{Plugins > Plugin
608 Manager}, and selecting @code{LilyTool} from the @key{Install} tab.
612 All these editors can be made to jump into the input file to the source
613 of a symbol in the graphical output. See @ref{Point and click}.