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. See TRANSLATION for details.
13 @node Running lilypond
14 @chapter Running @command{lilypond}
16 This chapter details the technicalities of running LilyPond.
20 * Command-line usage::
28 Most users run LilyPond through a GUI; see
30 @c @rlearning{First steps} if
31 you have not read this already.
34 @node Command-line usage
35 @section Command-line usage
37 This section contains extra information about using LilyPond on the
38 command-line. This may be desirable to pass extra options to the
39 program. In addition, there are certain extra @q{helper} programs (such
40 as @code{midi2ly}) which are only available on the command-line.
42 By @q{command-line}, we mean the command line in the operating system.
43 Windows users might be more familiar with the terms @q{DOS shell} or
44 @q{command shell}; MacOS@tie{}X users might be more familiar with the terms
45 @q{terminal} or @q{console}. They should also consult
47 @c @ref{Setup for MacOS X}.
49 Describing how to use this part of an operating system is outside the
50 scope of this manual; please consult other documentation on this topic
51 if you are unfamiliar with the command-line.
55 * Command line options for lilypond::
56 * Environment variables::
59 @node Invoking lilypond
60 @subsection Invoking @command{lilypond}
62 @cindex Invoking @command{lilypond}
63 @cindex command line options for @command{lilypond}
64 @cindex options, command line
68 The @command{lilypond} executable may be called as follows from the command line.
71 lilypond [@var{option}]@dots{} @var{file}@dots{}
75 When invoked with a filename that has no extension, the @file{.ly}
76 extension is tried first. To read input from stdin, use a
77 dash (@code{-}) for @var{file}.
79 When @file{filename.ly} is processed it will produce @file{filename.ps}
80 and @file{filename.pdf} as output. Several files can be specified;
81 they will each be processed independently. @footnote{The status of
82 GUILE is not reset after processing a @code{.ly} file, so be careful
83 not to change any system defaults from within Scheme.}
85 If @file{filename.ly} contains more than one @code{\score}
86 block, then the rest of the scores will be output in numbered files,
87 starting with @file{filename-1.pdf}. In addition, the value of
88 @code{output-suffix} will be inserted between the basename and the
89 number. An input file containing
92 #(define output-suffix "violin")
94 #(define output-suffix "cello")
99 will output @var{base}@file{-violin.pdf} and
100 @var{base}@file{-cello-1.pdf}.
103 @node Command line options for lilypond
104 @subsection Command line options for @command{lilypond}
106 The following options are supported:
110 @item -e,--evaluate=@var{expr}
111 Evaluate the Scheme @var{expr} before parsing any @file{.ly} files.
112 Multiple @code{-e} options may be given, they will be evaluated
115 The expression will be evaluated in the @code{guile-user} module, so
116 if you want to use definitions in @var{expr}, use
119 lilypond -e '(define-public a 42)'
123 on the command-line, and include
126 #(use-modules (guile-user))
130 at the top of the @code{.ly} file.
132 @item -f,--format=@var{format}
133 which formats should be written. Choices for @code{format} are
134 @code{svg}, @code{ps}, @code{pdf}, and @code{png}.
136 Example: @code{lilypond -fpng @var{filename}.ly}
140 @item -d,--define-default=@var{var}=@var{val}
141 This sets the internal program option @var{var} to the Scheme value
142 @var{val}. If @var{val} is not supplied, then @var{#t} is used. To
143 switch off an option, @code{no-} may be prefixed to @var{var}, e.g.
145 @cindex point and click, command line
154 -dpoint-and-click='#f'
157 Here are a few interesting options.
161 Running @code{lilypond -dhelp} will print all of the @code{-d} options
165 This option sets the default paper-size,
167 -dpaper-size=\"letter\"
171 Note that the string must be enclosed in escaped quotes ( @code{\"} ).
172 @c Match " in previous line to help context-sensitive editors
175 Do not trust the @code{.ly} input.
177 When LilyPond formatting is available through a web server, either the
178 @code{--safe} or the @code{--jail} option @b{MUST} be passed. The
179 @code{--safe} option will prevent inline Scheme code from wreaking
186 c4^#(ly:export (ly:gulp-file "/etc/passwd"))
191 The @code{-dsafe} option works by evaluating in-line Scheme
192 expressions in a special safe module. This safe module is derived from
193 GUILE @file{safe-r5rs} module, but adds a number of functions of the
194 LilyPond API. These functions are listed in @file{scm/@/safe@/-lily@/.scm}.
196 In addition, safe mode disallows @code{\include} directives and
197 disables the use of backslashes in @TeX{} strings.
199 In safe mode, it is not possible to import LilyPond variables
202 @code{-dsafe} does @emph{not} detect resource overuse. It is still possible to
203 make the program hang indefinitely, for example by feeding cyclic data
204 structures into the backend. Therefore, if using LilyPond on a
205 publicly accessible webserver, the process should be limited in both
206 CPU and memory usage.
208 The safe mode will prevent many useful LilyPond snippets from being
209 compiled. The @code{--jail} is a more secure alternative, but
210 requires more work to set up.
212 @cindex output format, setting
214 the output format to use for the back-end. Choices for @code{format} are
217 @cindex PostScript output
220 Postscript files include TTF, Type1 and OTF fonts. No subsetting of
221 these fonts is done. When using oriental character sets, this can
225 for encapsulated PostScript. This dumps every page (system) as a separate
226 @file{EPS} file, without fonts, and as one collated @file{EPS} file with
227 all pages (systems) including fonts.
229 This mode is used by default by @command{lilypond-book}.
232 @cindex SVG (Scalable Vector Graphics)
233 for SVG (Scalable Vector Graphics).
235 This creates a single SVG file containing the entire music output
236 with no embedded fonts. It is recommended to install the Century
237 Schoolbook fonts, included with your LilyPond installation, for
238 optimal rendering. Under UNIX, simply copy these fonts from the
239 LilyPond directory (typically
240 @file{/usr/share/lilypond/VERSION/fonts/otf/}) to
241 @file{~/.fonts/}. The SVG output should be compatible with any
242 SVG editor or user agent.
246 for a dump of the raw, internal Scheme-based drawing commands.
249 do not output a printed score; has the same effect as @code{-dno-print-pages}.
252 Example: @code{lilypond -dbackend=svg @var{filename}.ly}
255 Generate an output file containing the titles and the first system
258 Generate the full pages, the default. @code{-dno-print-pages} is
259 useful in combination with @code{-dpreview}.
266 Show a summary of usage.
268 @item -H,--header=@var{FIELD}
269 Dump a header field to file @file{BASENAME.@var{FIELD}}.
271 @item --include, -I=@var{directory}
272 Add @var{directory} to the search path for input files.
273 @cindex file searching
276 @item -i,--init=@var{file}
277 Set init file to @var{file} (default: @file{init.ly}).
279 @item -o,--output=@var{FILE}
280 Set the default output file to @var{FILE}. The appropriate
281 suffix will be added (e.g. @code{.pdf} for pdf)
287 Generate pictures of each page, in PNG format. This implies
288 @code{--ps}. The resolution in DPI of the image may be set with
294 Generate PDF. This implies @code{--ps}.
298 @item -j,--jail=@var{user},@var{group},@var{jail},@var{dir}
299 Run @command{lilypond} in a chroot jail.
301 The @code{--jail} option provides a more flexible alternative to
302 @code{--safe} when LilyPond formatting is available through a web
303 server or whenever LilyPond executes externally provided
306 The @code{--jail} option works by changing the root of @command{lilypond} to
307 @var{jail} just before starting the actual compilation process. The user
308 and group are then changed to match those provided, and the current
309 directory is changed to @var{dir}. This setup guarantees that it is not
310 possible (at least in theory) to escape from the jail. Note that for
311 @code{--jail} to work @command{lilypond} must be run as root, which is usually
312 accomplished in a safe way using @command{sudo}.
314 Setting up a jail is a slightly delicate matter, as we must be sure that
315 LilyPond is able to find whatever it needs to compile the source
316 @emph{inside the jail}. A typical setup comprises the following items:
319 @item Setting up a separate filesystem
320 A separate filesystem should be created for LilyPond, so that it can be
321 mounted with safe options such as @code{noexec}, @code{nodev}, and
322 @code{nosuid}. In this way, it is impossible to run executables or to
323 write directly to a device from LilyPond. If you do not want to create a
324 separate partition, just create a file of reasonable size and use it to
325 mount a loop device. A separate filesystem also guarantees that LilyPond
326 cannot write more space than it is allowed.
328 @item Setting up a separate user
329 A separate user and group (say, @code{lily}/@code{lily}) with low
330 privileges should be used to run LilyPond inside the jail. There should
331 be a single directory writable by this user, which should be passed in
334 @item Preparing the jail
335 LilyPond needs to read a number of files while running. All these files
336 are to be copied into the jail, under the same path they appear in the
337 real root filesystem. The entire content of the LilyPond installation
338 (e.g., @file{/usr/share/lilypond})
341 If problems arise, the simplest way to trace them down is to run
342 LilyPond using @command{strace}, which will allow you to determine which
345 @item Running LilyPond
346 In a jail mounted with @code{noexec} it is impossible to execute any external
347 program. Therefore LilyPond must be run with a backend that does not
348 require any such program. As we already mentioned, it must be also run
349 with superuser privileges (which, of course, it will lose immediately),
350 possibly using @command{sudo}. It is a good idea to limit the number of
351 seconds of CPU time LilyPond can use (e.g., using @command{ulimit
352 -t}), and, if your operating system supports it, the amount of memory
353 that can be allocated.
358 Show version information.
361 Be verbose: show full paths of all files read, and give timing
365 Show the warranty with which GNU LilyPond comes. (It comes with
366 @strong{NO WARRANTY}!)
369 @node Environment variables
370 @subsection Environment variables
374 @cindex LILYPOND_DATADIR
376 @command{lilypond} recognizes the following environment variables:
378 @item LILYPOND_DATADIR
379 This specifies a directory where locale messages and
380 data files will be looked up by default. The directory should contain
381 subdirectories called @file{ly/}, @file{ps/}, @file{tex/}, etc.
384 This selects the language for the warning messages.
386 @item LILYPOND_GC_YIELD
387 With this variable the memory footprint and performance can be
388 adjusted. It is a percentage tunes memory management behavior. With
389 higher values, the program uses more memory, with smaller values, it
390 uses more CPU time. The default value is @code{70}.
396 @section Error messages
398 @cindex error messages
399 Different error messages can appear while compiling a file:
405 Something looks suspect. If you are requesting something out of the
406 ordinary then you will understand the message, and can ignore it.
407 However, warnings usually indicate that something is wrong with the
411 Something is definitely wrong. The current processing step (parsing,
412 interpreting, or formatting) will be finished, but the next step will
418 Something is definitely wrong, and LilyPond cannot continue. This
419 happens rarely. The most usual cause is misinstalled fonts.
422 @cindex trace, Scheme
425 Errors that occur while executing Scheme code are caught by the Scheme
426 interpreter. If running with the verbose option (@code{-V} or
427 @code{--verbose}) then a call trace of the offending
428 function call is printed.
430 @item Programming error
431 @cindex Programming error
432 There was some internal inconsistency. These error messages are
433 intended to help the programmers and debuggers. Usually, they can be
434 ignored. Sometimes, they come in such big quantities that they obscure
437 @item Aborted (core dumped)
438 This signals a serious programming error that caused the program to
439 crash. Such errors are considered critical. If you stumble on one,
443 @cindex errors, message format
444 If warnings and errors can
445 be linked to some part of the input file, then error messages have the
449 @var{filename}:@var{lineno}:@var{columnno}: @var{message}
450 @var{offending input line}
453 A line-break is inserted in the offending line to indicate the column
454 where the error was found. For example,
457 test.ly:2:19: error: not a duration: 5
462 These locations are LilyPond's best guess about where the warning or
463 error occurred, but (by their very nature) warnings and errors occur
464 when something unexpected happens. If you can't see an error in the
465 indicated line of your input file, try checking one or two lines
466 above the indicated position.