1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @c This file is part of lilypond-program.tely
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. See TRANSLATION for details.
11 @node Running LilyPond
12 @chapter Running LilyPond
14 This chapter details the technicalities of running LilyPond.
16 Some of these commands are run from the command-line. By
17 @q{command-line}, we mean the command
18 line in the operating system. Windows users
19 might be more familiar with the terms @q{DOS shell} or
20 @q{command shell}; OSX users might be more familiar with the
21 terms @q{terminal} or @q{console}. OSX users should also
22 consult @ref{Notes for the MacOS X app}.
25 this part of an operating system is outside the scope of this
26 manual; please consult other documentation on this topic if
27 you are unfamiliar with the command-line.
31 * Updating files with convert-ly::
36 @node Invoking lilypond
37 @section Invoking lilypond
38 @cindex Invoking LilyPond
39 @cindex command line options
40 @cindex options, command line
44 The @code{lilypond} executable may be called as follows from the command line.
47 lilypond [@var{option}]@dots{} @var{file}@dots{}
51 When invoked with a filename that has no extension, the @file{.ly}
52 extension is tried first. To read input from stdin, use a
53 dash (@code{-}) for @var{file}.
55 When @file{filename.ly} is processed it will produce
56 @file{filename.tex} as output (or @file{filename.ps} for PostScript
57 output). If @file{filename.ly} contains more than one @code{\score}
58 block, then the rest of the scores will be output in numbered files,
59 starting with @file{filename-1.tex}. Several files can be specified;
60 they will each be processed independently. @footnote{The status of
61 GUILE is not reset after processing a @code{.ly} file, so be careful
62 not to change any system defaults from within Scheme.}
65 @subsection Command line options
67 The following options are supported:
71 @item -e,--evaluate=@var{expr}
72 Evaluate the Scheme @var{expr} before parsing any @file{.ly} files.
73 Multiple @code{-e} options may be given, they will be evaluated
76 The expression will be evaluated in the @code{guile-user} module, so
77 if you want to use definitions in @var{expr}, use
80 lilypond -e '(define-public a 42)'
84 on the command-line, and include
87 #(use-modules (guile-user))
91 at the top of the @code{.ly} file.
93 @item -f,--format=@var{format}
94 which formats should be written. Choices for @code{format} are
95 @code{svg}, @code{ps}, @code{pdf}, @code{png}, @code{tex}, @code{dvi}.
97 Example: @code{lilypond -fpng filename.ly}
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}, e.g.
106 @cindex point and click, command line
115 -dpoint-and-click='#f'
118 Here are a few interesting options.
122 Running @code{lilypond -dhelp} will print all of the @code{-d} options
126 This option sets the default paper-size,
128 -dpaper-size=\"letter\"
132 Note that the string must be enclosed in escaped quotes ( @code{\"} ).
136 Do not trust the @code{.ly} input.
138 When LilyPond formatting is available through a web server, either the
139 @code{--safe} or the @code{--jail} option @b{MUST} be passed. The
140 @code{--safe} option will prevent inline Scheme code from wreaking
147 c4^#(ly:export (ly:gulp-file "/etc/passwd"))
152 The @code{-dsafe} option works by evaluating in-line Scheme
153 expressions in a special safe module. This safe module is derived from
154 GUILE @file{safe-r5rs} module, but adds a number of functions of the
155 LilyPond API. These functions are listed in @file{scm/@/safe@/-lily@/.scm}.
157 In addition, safe mode disallows @code{\include} directives and
158 disables the use of backslashes in @TeX{} strings.
160 In safe mode, it is not possible to import LilyPond variables
163 safe does @emph{not} detect resource overuse. It is still possible to
164 make the program hang indefinitely, for example by feeding cyclic data
165 structures into the backend. Therefore, if using LilyPond on a
166 publicly accessible webserver, the process should be limited in both
167 CPU and memory usage.
169 The safe mode will prevent many useful LilyPond snippets from being
170 compiled. The @code{--jail} is a more secure alternative, but
171 requires more work to set up.
174 the output format to use for the back-end. Choices for @code{format} are
177 for @TeX{} output, to be processed with La@TeX{}. If present, the file
178 @file{file.textmetrics} is read to determine text extents.
180 dump text strings to @file{.texstr} file, which can be run through
181 (La)@TeX{}, resulting in a @code{.textmetrics} file, which contains the
182 extents of strings of text. @strong{Warning:} this functionality is
183 currently missing due to heavy restructuring of the source code.
186 @cindex PostScript output
188 Postscript files include TTF, Type1 and OTF fonts. No subsetting of
189 these fonts is done. When using oriental character sets, this can
193 for encapsulated PostScript. This dumps every page (system) as a separate
194 @file{EPS} file, without fonts, and as one collated @file{EPS} file with
195 all pages (systems) including fonts.
197 This mode is used by default by lilypond-book.
200 for SVG (Scalable Vector Graphics). This dumps every page as a separate
201 @file{SVG} file, with embedded fonts.
202 @cindex SVG (Scalable Vector Graphics)
203 You need a SVG viewer which supports embedded fonts, or a SVG
204 viewer which is able to replace the embedded fonts with OTF fonts.
205 Under Unix, you may use @uref{http://www.inkscape.org,Inkscape}
206 (version 0.42 or later), after copying the OTF fonts in directory
207 @file{PATH/TO/share/lilypond/VERSION/fonts/otf/} to @file{~/.fonts/}.
209 for a dump of the raw, internal Scheme-based drawing commands.
213 Example: @code{lilypond -dbackend=svg filename.ly}
215 @cindex output format, setting
218 Generate an output file containing the titles and the first system
221 Generate the full pages, the default. @code{-dno-print-pages} is
222 useful in combination with @code{-dpreview}.
229 Show a summary of usage.
231 @item -H,--header=FIELD
232 Dump a header field to file BASENAME.FIELD
234 @item --include, -I=@var{directory}
235 Add @var{directory} to the search path for input files.
236 @cindex file searching
239 @item -i,--init=@var{file}
240 Set init file to @var{file} (default: @file{init.ly}).
242 @item -o,--output=@var{FILE}
243 Set the default output file to @var{FILE}. The appropriate
244 suffix will be added (ie @code{.pdf} for pdf, @code{.tex}
251 Generate DVI files. In this case, the @TeX{} backend should be
252 specified, i.e., @code{-dbackend=tex}.
255 Generate pictures of each page, in PNG format. This implies
256 @code{--ps}. The resolution in DPI of the image may be set with
262 Generate PDF. This implies @code{--ps}.
266 @item -j,--jail=@var{user},@var{group},@var{jail},@var{dir}
267 Run LilyPond in a chroot jail.
269 The @code{--jail} option provides a more flexible alternative to
270 @code{--safe} when LilyPond formatting is available through a web
271 server or whenever LilyPond executes externally provided
274 The @code{--jail} option works by changing the root of LilyPond to
275 @var{jail} just before starting the actual compilation process. The user
276 and group are then changed to match those provided, and the current
277 directory is changed to @var{dir}. This setup guarantees that it is not
278 possible (at least in theory) to escape from the jail. Note that for
279 @code{--jail} to work LilyPond must be run as root, which is usually
280 accomplished in a safe way using @command{sudo}.
282 Setting up a jail is a slightly delicate matter, as we must be sure that
283 LilyPond is able to find whatever it needs to compile the source
284 @emph{inside the jail}. A typical setup comprises the following items:
287 @item Setting up a separate filesystem
288 A separate filesystem should be created for LilyPond, so that it can be
289 mounted with safe options such as @code{noexec}, @code{nodev}, and
290 @code{nosuid}. In this way, it is impossible to run executables or to
291 write directly to a device from LilyPond. If you do not want to create a
292 separate partition, just create a file of reasonable size and use it to
293 mount a loop device. A separate filesystem also guarantees that LilyPond
294 cannot write more space than it is allowed.
296 @item Setting up a separate user
297 A separate user and group (say, @samp{lily}/@samp{lily}) with low
298 privileges should be used to run LilyPond inside the jail. There should
299 be a single directory writable by this user, which should be passed in
302 @item Preparing the jail
303 LilyPond needs to read a number of files while running. All these files
304 are to be copied into the jail, under the same path they appear in the
305 real root filesystem. The entire content of the LilyPond installation
306 (e.g., @file{/usr/share/lilypond})
309 If problems arise, the simplest way to trace them down is to run
310 LilyPond using @command{strace}, which will allow you to determine which
313 @item Running LilyPond
314 In a jail mounted with @code{noexec} it is impossible to execute any external
315 program. Therefore LilyPond must be run with a backend that does not
316 require any such program. As we already mentioned, it must be also run
317 with superuser privileges (which, of course, it will lose immediately),
318 possibly using @command{sudo}. It is a good idea to limit the number of
319 seconds of CPU time LilyPond can use (e.g., using @command{ulimit
320 -t}), and, if your operating system supports it, the amount of memory
321 that can be allocated.
326 Show version information.
329 Be verbose: show full paths of all files read, and give timing
333 Show the warranty with which GNU LilyPond comes. (It comes with
334 @strong{NO WARRANTY}!)
338 @subsection Environment variables
342 @cindex LILYPOND_DATADIR
344 @code{Lilypond} recognizes the following environment variables:
346 @item LILYPOND_DATADIR
347 This specifies a directory where locale messages and
348 data files will be looked up by default. The directory should contain
349 subdirectories called @file{ly/}, @file{ps/}, @file{tex/}, etc.
352 This selects the language for the warning messages.
354 @item LILYPOND_GC_YIELD
355 With this variable the memory footprint and performance can be
356 adjusted. It is a percentage tunes memory management behavior. With
357 higher values, the program uses more memory, with smaller values, it
358 uses more CPU time. The default value is @code{70}.
363 @node Updating files with convert-ly
364 @section Updating with @command{convert-ly}
366 @cindex Updating a LilyPond file
369 The LilyPond input syntax is routinely changed to simplify it or improve
370 it in different ways. As a side effect of this, the LilyPond interpreter
371 often is no longer compatible with older input files. To remedy this,
372 the program @command{convert-ly} can be used to deal with most of the
373 syntax changes between LilyPond versions.
375 It uses @code{\version} statements in the input files to detect the
376 old version number. In most cases, to upgrade your input file it is
377 sufficient to run@footnote{MacOS X users may execute this command
378 under the menu entry @samp{Compile > Update syntax}.}
381 convert-ly -e myfile.ly
384 If there are no changes to myfile.ly and file called myfile.ly.NEW
385 is created, then myfile.ly is already updated.
387 @command{convert-ly} always converts up to the last syntax change handled by
388 it. This means that the @code{\version} number left in the file is
389 usually lower than the version of @command{convert-ly} itself.
391 To upgrade LilyPond fragments in texinfo files, use
394 convert-ly --from=... --to=... --no-version *.itely
397 To see the changes in the LilyPond syntax between two versions, use
400 convert-ly --from=... --to=... -s
403 To upgrade many files at once, combine @code{convert-ly} with
404 standard unix commands. This example will upgrade all @code{.ly}
405 files in the current directory
408 for f in *.ly; do convert-ly -e $f; done;
411 In general, the program is invoked as follows:
414 convert-ly [@var{option}]@dots{} @var{file}@dots{}
418 The following options can be given:
422 Do an inline edit of the input file. Overrides @code{--output}.
424 @item -f,--from=@var{from-patchlevel}
425 Set the version to convert from. If this is not set, @command{convert-ly}
426 will guess this, on the basis of @code{\version} strings in the file.
428 @item -n,--no-version
429 Normally, @command{convert-ly} adds a @code{\version} indicator
430 to the output. Specifying this option suppresses this.
432 @item -s, --show-rules
433 Show all known conversions and exit.
435 @item --to=@var{to-patchlevel}
436 Set the goal version of the conversion. It defaults to the latest
446 Not all language changes are handled. Only one output option can be
447 specified. Automatically updating scheme and lilypond scheme
448 interfaces is quite unlikely; be prepared to tweak scheme code
452 @c We might want to make this a completely new section, along with more
453 @c info about how to upgrade old input files. -gp
456 Copy and paste from CVS, last updated
459 http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/lilypond/lily-bugs/bugs/
460 convert-ly.txt?rev=HEAD&content-type=text/plain
462 NEW: not exactly copied; this list has been modified. Since we're
463 changing the bug system, it doesn't make sense to copy from
464 the bug CVS any more. I'll figure out something else. -gp
468 There are a few things that the convert-ly cannot handle. Here's a list of
470 that the community has complained about.
472 This bug report structure has been chosen because convert-ly has a structure
474 allow to smoothly implement all needed changes. Thus this is just a wishlist,
479 Doesn't always convert figured bass correctly, specifically things like {<
480 >}. Mats' comment on working around this:
481 To be able to run convert-ly
482 on it, I first replaced all occurencies of '{<' to some dummy like '{#'
483 and similarly I replaced '>}' with '&}'. After the conversion, I could
484 then change back from '{ #' to '{ <' and from '& }' to '> }'.
485 Doesn't convert all text markup correctly. In the old markup syntax,
486 it was possible to group a number of markup commands together within
488 -#'((bold italic) "string")
489 This will incorrectly be converted into
490 -\markup{{\bold italic} "string"}
491 instead of the correct
492 -\markup{\bold \italic "string"}
494 Doesn't handle \partcombine
495 Doesn't do \addlyrics => \lyricsto, this breaks some scores with multiple
498 \magnify isn't changed to \fontsize.
499 - \magnify #m => \fontsize #f, where f = 6ln(m)/ln(2)
500 remove-tag isn't changed.
501 - \applyMusic #(remove-tag '. . .) => \keepWithTag #'. . .
502 first-page-number isn't changed.
503 - first-page-number no => print-first-page-number = ##f
504 Line breaks in header strings aren't converted.
505 - \\\\ as line break in \header strings => \markup \center-align <
506 "First Line" "Second Line" >
507 Crescendo and decrescendo terminators aren't converted.
511 \turnOff (used in \set Staff.VoltaBracket = \turnOff) is not properly
514 \markup{ \center-align <{ ... }> } should be converted to:
515 \markup{ \center-align {\line { ... }} }
516 but now, \line is missing.
518 Special LaTeX characters such as $~$ in text are not converted to UTF8.
520 \score{} must now begin with a music expression. Anything else
521 (particularly \header{}) must come after the music.
526 @section Reporting bugs
529 @cindex reporting bugs
531 If you have input that results in a crash or an erroneous output, then
532 that is a bug. There is a list of current bugs on our google bug tracker,
534 @uref{http://code.google.com/p/lilypond/issues/list}
536 If you have discovered a bug which is not listed, please report the
537 bug by following the directions on
539 @uref{http://lilypond.org/web/devel/participating/bugs}
541 Please construct submit @ruser{Minimal examples}, of bug reports. We do not
542 have the resources to investigate reports which are not as small as possible.
546 @section Error messages
548 @cindex error messages
549 Different error messages can appear while compiling a file:
555 Something looks suspect. If you are requesting something out of the
556 ordinary then you will understand the message, and can ignore it.
557 However, warnings usually indicate that something is wrong with the
561 Something is definitely wrong. The current processing step (parsing,
562 interpreting, or formatting) will be finished, but the next step will
568 Something is definitely wrong, and LilyPond cannot continue. This
569 happens rarely. The most usual cause is misinstalled fonts.
571 @cindex trace, Scheme
575 Errors that occur while executing Scheme code are caught by the Scheme
576 interpreter. If running with the verbose option (@code{-V} or
577 @code{--verbose}) then a call trace of the offending
578 function call is printed.
580 @cindex Programming error
581 @item Programming error
582 There was some internal inconsistency. These error messages are
583 intended to help the programmers and debuggers. Usually, they can be
584 ignored. Sometimes, they come in such big quantities that they obscure
585 other output. In this case, file a bug-report.
587 @item Aborted (core dumped)
588 This signals a serious programming error that caused the program to
589 crash. Such errors are considered critical. If you stumble on one,
595 @cindex errors, message format
596 If warnings and errors can
597 be linked to some part of the input file, then error messages have the
601 @var{filename}:@var{lineno}:@var{columnno}: @var{message}
602 @var{offending input line}
605 A line-break is inserted in the offending line to indicate the column
606 where the error was found. For example,
609 test.ly:2:19: error: not a duration: 5:
614 These locations are LilyPond's best guess about where the warning or
615 error occurred, but (by their very nature) warnings and errors occur
616 when something unexpected happens. If you can't see an error in the
617 indicated line of your input file, try checking one or two lines
618 above the indicated position.