]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/usage/running.itely
Reduce size of PDF files when inc. in *TeX docs
[lilypond.git] / Documentation / usage / running.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2
3 @ignore
4     Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
5
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..
9 @end ignore
10
11 @c \version "2.17.6"
12
13
14 @node Running lilypond
15 @chapter Running @command{lilypond}
16
17 This chapter details the technicalities of running LilyPond.
18
19 @menu
20 * Normal usage::
21 * Command-line usage::
22 * Error messages::
23 * Common errors::
24 @end menu
25
26
27 @node Normal usage
28 @section Normal usage
29
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
33 program.
34
35
36 @node Command-line usage
37 @section Command-line usage
38
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.
43
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}.
49
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.
53
54 @menu
55 * Invoking LilyPond::
56 * Basic command line options for LilyPond::
57 * Advanced command line options for LilyPond::
58 * Environment variables::
59 * LilyPond in chroot jail::
60 @end menu
61
62 @node Invoking LilyPond
63 @unnumberedsubsec Invoking @command{lilypond}
64
65 The @command{lilypond} executable may be called as follows from
66 the command line.
67
68 @example
69 lilypond [@var{option}]@dots{} @var{file}@dots{}
70 @end example
71
72 When invoked with a filename that has no extension, the @file{.ly}
73 extension is tried first.  To read input from stdin, use a
74 dash (@code{-}) for @var{file}.
75
76 When @file{filename.ly} is processed it will produce @file{filename.ps}
77 and @file{filename.pdf} as output.  Several files can be specified;
78 they will each be processed independently.  @footnote{The status of
79 GUILE is not reset after processing a @code{.ly} file, so be careful
80 not to change any system defaults from within Scheme.}
81
82 If @file{filename.ly} contains more than one @code{\book}
83 block, then the rest of the scores will be output in numbered files,
84 starting with @file{filename-1.pdf}.  In addition, the value of
85 @code{output-suffix} will be inserted between the basename and the
86 number.  An input file containing
87
88 @example
89 #(define output-suffix "violin")
90 \score @{ @dots{} @}
91 #(define output-suffix "cello")
92 \score @{ @dots{} @}
93 @end example
94
95 @noindent
96 will output @var{base}@file{-violin.pdf} and
97 @var{base}@file{-cello-1.pdf}.
98
99
100 @unnumberedsubsubsec Using LilyPond with standard shell features
101
102 Since LilyPond is a command line application, features of the @q{shell}
103 used for calling LilyPond can also be put to good use.
104
105 For example:
106
107 @example
108 lilypond *.ly
109 @end example
110
111 @noindent
112 will process all LilyPond files in the current directory.
113
114 Redirecting the console output (e.g. to a file) may also be useful:
115
116 @example
117 lilypond file.ly 1> stdout.txt
118
119 lilypond file.ly 2> stderr.txt
120
121 lilypond file.ly &> all.txt
122 @end example
123
124 @noindent
125 Redirects @q{normal} output, @q{errors} only or @q{everything},
126 respectively, to a text file.  Consult the documentation for your
127 particular shell, Command (Windows), Terminal or Console
128 applications (MacOS X) to see if output redirection is supported or if
129 the syntax is different.
130
131 The following example searches and processes all input files in the
132 current directory and all directories below it recursively.  The output
133 files will be located in the same directory that the command was run in,
134 rather than in the same directories as the original input files.
135
136 @example
137 find . -name '*.ly' -exec lilypond '@{@}' \;
138 @end example
139
140 @noindent
141 This should also work for MacOS@tie{}X users.
142
143 A Windows user would run;
144
145 @example
146 forfiles /s /M *.ly /c "cmd /c lilypond @@file"
147 @end example
148
149 @noindent
150 entering these commands in a @code{command prompt} usually found under
151 @code{Start > Accessories > Command Prompt} or for version 8 users,
152 by typing in the search window @q{command prompt}.
153
154 Alternatively, an explicit path to the top-level of your folder
155 containing all the sub-folders that have input files in them can be
156 stated using the @code{/p} option;
157
158 @example
159 forfiles /s /p C:\Documents\MyScores /M *.ly /c "cmd /c lilypond @@file"
160 @end example
161
162 If there are spaces in the path to the top-level folder, then the whole
163 path needs to be inside double quotes;
164
165 @example
166 forfiles /s /p "C:\Documents\My Scores" /M *.ly /c "cmd /c lilypond @@file"
167 @end example
168
169
170 @node Basic command line options for LilyPond
171 @unnumberedsubsec Basic command line options for LilyPond
172
173 @cindex Invoking @command{lilypond}
174 @cindex command line options for @command{lilypond}
175 @cindex options, command line
176 @cindex switches
177
178 The following options are supported:
179
180 @table @code
181
182 @item -b, --bigpdfs
183 @cindex bigpdfs
184
185 PDF files generated will be much larger than normal (due to little or no
186 font optimization).  However, if two or more PDF files are included
187 within @w{@code{pdftex}}, @w{@code{xetex}} or @w{@code{luatex}}
188 documents they can then be processed further via ghostscript (merging
189 duplicated font data) resulting in @emph{significantly} smaller PDF
190 files.
191
192 @example
193 lilypond -b myfile
194 @end example
195
196 Then run @code{ghostscript};
197
198 @example
199 gs -q -sDEVICE=pdfwrite -o gsout.pdf myfile.pdf
200 @end example
201
202 @code{pdfsizeopt.py} can then be used to further optimize the size
203 of file;
204
205 @example
206 pdfsizeopt.py --use-multivalent=no gsout.pdf final.pdf
207 @end example
208
209
210 @item -d, --define-default=@var{var}=@var{val}
211 See @ref{Advanced command line options for LilyPond}.
212
213 @cindex Scheme, expression evaluation
214 @cindex expression evaluation, Scheme
215
216 @item -e, --evaluate=@var{expr}
217 Evaluate the Scheme @var{expr} before parsing any @file{.ly} files.
218 Multiple @option{-e} options may be given, they will be evaluated
219 sequentially.
220
221 The expression will be evaluated in the @code{guile-user} module, so
222 if you want to use definitions in @var{expr}, use
223
224 @example
225 lilypond -e '(define-public a 42)'
226 @end example
227
228 @noindent
229 on the command-line, and include
230
231 @example
232 #(use-modules (guile-user))
233 @end example
234
235 @noindent
236 at the top of the @code{.ly} file.
237
238 @warning{Windows users must use double quotes instead of single quotes.}
239
240 @cindex output, format
241 @cindex format, output
242
243 @item -f, --format=@var{format}
244 which formats should be written.  Choices for @code{format} are
245 @code{ps}, @code{pdf}, and @code{png}.
246
247 Example: @code{lilypond -fpng @var{filename}.ly}
248
249 @item -h, --help
250 Show a summary of usage.
251
252 @item -H, --header=@var{FIELD}
253 Dump a header field to file @file{BASENAME.@var{FIELD}}.
254
255 @item -i, --init=@var{file}
256 Set init file to @var{file} (default: @file{init.ly}).
257
258 @cindex file searching
259 @cindex search path
260
261 @item -I, --include=@var{directory}
262 Add @var{directory} to the search path for input files.
263
264 Multiple -I options may be given.  The search will start in the first
265 defined directory, and if the file to be included is not found the
266 search will continue in subsequent directories.
267
268 @cindex chroot jail, running inside
269
270 @item -j, --jail=@var{user},@var{group},@var{jail},@var{dir}
271 Run @command{lilypond} in a chroot jail.
272
273 The @option{--jail} option provides a more flexible alternative to
274 @option{-dsafe}, when LilyPond formatting is being provided via a web
275 server, or whenever LilyPond executes commands sent by external sources
276 (see @ref{Advanced command line options for LilyPond}).
277
278 It works by changing the root of @command{lilypond} to @var{jail} just
279 before starting the actual compilation process.  The user and group are
280 then changed to match those provided, and the current directory is
281 changed to @var{dir}.  This setup guarantees that it is not possible (at
282 least in theory) to escape from the jail.  Note that for @option{--jail}
283 to work, @command{lilypond} must be run as root, which is usually
284 accomplished in a safe way using @command{sudo}.
285
286 Setting up a jail can be a relatively complex matter, as we must be sure
287 that LilyPond is able to find whatever it needs to compile the source
288 @emph{inside} the jail itself.  A typical chroot jail will comprise the
289 following steps:
290
291 @table @asis
292
293 @item Setting up a separate filesystem
294 A separate filesystem should be created for LilyPond, so that it can be
295 mounted with safe options such as @code{noexec}, @code{nodev}, and
296 @code{nosuid}.  In this way, it is impossible to run executables or to
297 write directly to a device from LilyPond.  If you do not want to create a
298 separate partition, just create a file of reasonable size and use it to
299 mount a loop device.  A separate filesystem also guarantees that LilyPond
300 cannot write more space than it is allowed.
301
302 @item Setting up a separate user
303 A separate user and group (say, @code{lily}/@code{lily}) with low
304 privileges should be used to run LilyPond inside the jail.  There should
305 be a single directory writable by this user, which should be passed in
306 @var{dir}.
307
308 @item Preparing the jail
309 LilyPond needs to read a number of files while running.  All these files
310 are to be copied into the jail, under the same path they appear in the
311 real root filesystem.  The entire content of the LilyPond installation
312 (e.g., @file{/usr/share/lilypond}) should be copied.
313
314 If problems arise, the simplest way to trace them down is to run
315 LilyPond using @command{strace}, which will allow you to determine which
316 files are missing.
317
318 @item Running LilyPond
319 In a jail mounted with @code{noexec} it is impossible to execute any
320 external program.  Therefore LilyPond must be run with a backend that
321 does not require any such program.  As we have already mentioned, it
322 must be run with superuser privileges (which, of course, it will lose
323 immediately), possibly using @command{sudo}.  It is also good practice
324 to limit the number of seconds of CPU time LilyPond can use (e.g., using
325 @command{ulimit@tie{}-t}), and, if your operating system supports it,
326 the amount of memory that can be allocated.  Also see
327 @ref{LilyPond in chroot jail}.
328 @end table
329
330 @cindex loglevel
331 @cindex output, verbosity
332
333 @item -l, --loglevel=@var{LEVEL}
334 Set the verbosity of the console output to @var{LEVEL}. Possible values
335 are:
336
337 @table @code
338
339 @item NONE
340 No output at all, not even error messages.
341
342 @item ERROR
343 Only error messages, no warnings or progress messages.
344
345 @item WARN
346 Warnings and error messages, no progress.
347
348 @item BASIC_PROGRESS
349 Basic progress messages (success), warnings and errors.
350
351 @item PROGRESS
352 All progress messages, warnings and errors.
353
354 @item INFO (default)
355 Progress messages, warnings, errors and further execution information.
356
357 @item DEBUG
358 All possible messages, including verbose debug output.
359
360 @end table
361
362 @cindex directory, redirect output
363 @cindex output, setting filename
364 @cindex output, directory
365
366 @item -o, --output=@var{FILE} or @var{FOLDER}
367 Set the default output file to @var{FILE} or, if a folder with that name
368 exists, direct the output to @var{FOLDER}, taking the file name from the
369 input file.  The appropriate suffix will be added (e.g. @code{.pdf} for
370 pdf) in both cases.
371
372 @cindex PS (Postscript), output
373 @cindex Postscript (PS), output
374 @cindex output, PS (Postscript)
375
376 @item --ps
377 Generate PostScript.
378
379 @cindex PNG (Portable Network Graphics), output
380 @cindex output, PNG (Portable Network Graphics)
381
382 @item --png
383 Generate pictures of each page, in PNG format.  This implies
384 @option{--ps}.  The resolution in DPI of the image may be set with
385 @example
386 -dresolution=110
387 @end example
388
389 @cindex PDF (Portable Document Format), output
390 @cindex output, PDF (Portable Document Format)
391
392 @item --pdf
393 Generate PDF.  This implies @option{--ps}.
394
395 @item -v, --version
396 Show version information.
397
398 @item -V, --verbose
399 Be verbose: show full paths of all files read, and give timing
400 information.
401
402 @item -w, --warranty
403 Show the warranty with which GNU LilyPond comes.  (It comes with
404 @strong{NO WARRANTY}!)
405
406 @end table
407
408
409 @node Advanced command line options for LilyPond
410 @unnumberedsubsec Advanced command line options for LilyPond
411
412 @table @code
413
414 @item -d@var{[option-name]}=@var{[value]},--define-default=@var{[option-name]}=@var{[value]}
415 This sets the equivalent internal Scheme function to @var{value}.
416
417 @example
418 -dbackend=svg
419 @end example
420
421 If a @var{value} is not supplied, then the default value is used.  The
422 prefix @code{no-} may be added to @var{option-name} to switch @q{off} an
423 option, e.g.
424
425 @cindex point and click, command line
426
427 @example
428 -dpoint-and-click=#f
429 @end example
430
431 @noindent
432 is the same as
433 @example
434 -dno-point-and-click
435 @end example
436 @end table
437
438 @noindent The following are supported along with their respective
439 default values:
440
441 @multitable @columnfractions .33 .16 .51
442 @item @strong{Symbol}
443 @tab @strong{Value}
444 @tab @strong{Explanation/Options}
445
446 @item @code{anti-alias-factor}
447 @tab @code{1}
448 @tab Render at higher resolution (using given factor) and scale down
449 result to prevent @q{jaggies} in @code{PNG} images.
450
451 @item @code{aux-files}
452 @tab @code{#t}
453 @tab Create @code{.tex}, @code{.texi}, @code{.count} files in the
454 @code{EPS} backend.
455
456 @item @code{backend}
457 @tab @code{ps}
458 @tab Select backend.  Postscript files (default) include @code{TTF},
459 @code{Type1} and @code{OTF} fonts.  No subsetting of these fonts is
460 done.  Using @q{oriental} character sets can lead to very large files.
461
462 @item
463 @tab @code{eps}
464 @tab Encapsulated PostScript.  This dumps every page (system) as a
465 separate @file{EPS} file, without fonts, and as one collated @file{EPS}
466 file with all pages (systems) including fonts.  Used as default by
467 @command{lilypond-book}.
468
469 @item
470 @tab @code{null}
471 @tab Do not output a printed score; has the same effect as
472 @code{-dno-print-pages}.
473
474 @item
475 @tab @code{svg}
476 @tab Scalable Vector Graphics.  This creates a single SVG file,
477 without embedded fonts, for every page of output.  It is recommended to
478 install the Century Schoolbook fonts, included with your LilyPond
479 installation, for optimal rendering.  Under UNIX, simply copy these
480 fonts from the LilyPond directory (typically
481 @file{/usr/share/lilypond/VERSION/fonts/otf/}) to @file{~/.fonts/}.
482 There is also an option @code{svg-woff} (below) for use of woff font
483 files in the SVG backend.
484
485 @item
486 @tab @code{scm}
487 @tab Dump of the raw, internal Scheme-based drawing commands.
488
489 @item @code{check-internal-types}
490 @tab @code{#f}
491 @tab Check every property assignment for types.
492
493 @item @code{clip-systems}
494 @tab @code{#f}
495 @tab Extract music fragments out of a score.  This requires that the
496 @code{clip-regions} function has been defined within the @code{\layout}
497 block.  See @ruser{Extracting fragments of music}.  No fragments are
498 extracted though if used with the @option{-dno-print-pages} option.
499
500 @item @code{datadir}
501 @tab
502 @tab Prefix for data files (read-only).
503
504 @item @code{debug-gc}
505 @tab @code{#f}
506 @tab Dump memory debugging statistics.
507
508 @item @code{debug-gc-assert-parsed-dead}
509 @tab @code{#f}
510 @tab For memory debugging: Ensure that all references to parsed objects
511 are dead. This is an internal option, and is switched on automatically
512 for @code{`-ddebug-gc'}.
513
514 @item @code{debug-lexer}
515 @tab @code{#f}
516 @tab Debug the flex lexer.
517
518 @item @code{debug-page-breaking-scoring}
519 @tab @code{#f}
520 @tab Dump scores for many different page breaking configurations.
521
522 @item @code{debug-parser}
523 @tab @code{#f}
524 @tab Debug the bison parser.
525
526 @item @code{debug-property-callbacks}
527 @tab @code{#f}
528 @tab Debug cyclic callback chains.
529
530 @item @code{debug-skylines}
531 @tab @code{#f}
532 @tab Debug skylines.
533
534 @item @code{delete-intermediate-files}
535 @tab @code{#t}
536 @tab Delete the unusable, intermediate @code{.ps} files created during
537 compilation.
538
539 @item @code{dump-cpu-profile}
540 @tab @code{#f}
541 @tab Dump timing information (system-dependent).
542
543 @item @code{dump-profile}
544 @tab @code{#f}
545 @tab Dump memory and time information for each file.
546
547 @item @code{dump-signatures}
548 @tab @code{#f}
549 @tab Dump output signatures of each system. Used for regression testing.
550
551 @item @code{eps-box-padding}
552 @tab @code{#f}
553 @tab Pad left edge of the output EPS bounding box by the given amount
554 (in mm).
555
556 @item @code{gs-load-fonts}
557 @tab @code{#f}
558 @tab Load fonts via Ghostscript.
559
560 @item @code{gs-load-lily-fonts}
561 @tab @code{#f}
562 @tab Load only the LilyPond fonts via Ghostscript.
563
564 @item @code{gui}
565 @tab @code{#f}
566 @tab Runs silently and redirect all output to a log file.
567 @end multitable
568
569 @noindent
570 @strong{Note to Windows users:} By default @code{lilypond.exe} outputs
571 all progress information to the command window,
572 @code{lilypond-windows.exe} does not and returns a prompt, with no
573 progress information, immediately at the command line.  The
574 @option{-dgui} option can be used in this case to redirect output to a
575 log file.
576
577 @multitable @columnfractions .33 .16 .51
578 @item @code{help}
579 @tab @code{#f}
580 @tab Show this help.
581
582 @item @code{include-book-title-preview}
583 @tab @code{#t}
584 @tab Include book titles in preview images.
585
586 @item @code{include-eps-fonts}
587 @tab @code{#t}
588 @tab Include fonts in separate-system EPS files.
589
590 @item @code{include-settings}
591 @tab @code{#f}
592 @tab Include file for global settings, this is included before the score
593 is processed.
594
595 @item @code{job-count}
596 @tab @code{#f}
597 @tab Process in parallel, using the given number of jobs.
598
599 @item @code{log-file}
600 @tab @code{#f [file]}
601 @tab If string @code{FOO} is given as a second argument,
602 redirect output to the log file @code{FOO.log}.
603
604 @item @code{max-markup-depth}
605 @tab @code{1024}
606 @tab Maximum depth for the markup tree. If a markup has more levels,
607 assume it will not terminate on its own, print a warning and return a
608 null markup instead.
609
610 @item @code{midi-extension}
611 @tab @code{"midi"}
612 @tab Set the default file extension for MIDI output file to given
613 string.
614
615 @item @code{music-strings-to-paths}
616 @tab @code{#f}
617 @tab Convert text strings to paths when glyphs belong to a music font.
618
619 @item @code{paper-size}
620 @tab @code{\"a4\"}
621 @tab Set default paper size.  Note the string must be enclosed in
622 escaped double quotes.
623
624 @item @code{pixmap-format}
625 @tab @code{png16m}
626 @tab Set GhostScript's output format for pixel images.
627
628 @item @code{point-and-click}
629 @tab @code{#t}
630 @tab Add @q{point & click} links to PDF and SVG output.
631 See @ref{Point and click}.
632
633 @item @code{preview}
634 @tab @code{#f}
635 @tab Create preview images in addition to normal output.
636 @end multitable
637
638 @noindent
639 This option is supported by all backends; @code{pdf}, @code{png},
640 @code{ps}, @code{eps} and @code{svg}, but not @code{scm}.  It generates
641 an output file, in the form @code{myFile.preview.extension}, containing
642 the titles and the first system of music.  If @code{\book} or
643 @code{\bookpart} blocks are used, the titles of @code{\book},
644 @code{\bookpart} or @code{\score} will appear in the output, including
645 the first system of every @code{\score} block if the @code{\paper}
646 variable @code{print-all-headers} is set to @code{#t}.
647
648 To suppress the usual output, use the @option{-dprint-pages} or
649 @option{-dno-print-pages} options according to your requirements.
650
651 @multitable @columnfractions .33 .16 .51
652 @item @code{print-pages}
653 @tab @code{#t}
654 @tab Generate full pages, the default.  @option{-dno-print-pages} is
655 useful in combination with @option{-dpreview}.
656
657 @item @code{profile-property-accesses}
658 @tab @code{#f}
659 @tab Keep statistics of @code{get_property()} function calls.
660
661 @item @code{protected-scheme-parsing}
662 @tab @code{#t}
663 @tab Continue when errors in inline scheme are caught in the parser. If
664 set to @code{#f}, halt on errors and print a stack trace.
665
666 @item @code{read-file-list}
667 @tab @code{#f [file]}
668 @tab Specify name of a file which contains a list of input files to be
669 processed.
670
671 @item @code{relative-includes}
672 @tab @code{#f}
673 @tab When processing an @code{\include} command, look for the included
674 file relative to the current file (instead of the root file).
675
676 @item @code{resolution}
677 @tab @code{101}
678 @tab Set resolution for generating @code{PNG} pixmaps to given value (in
679 dpi).
680
681 @item @code{safe}
682 @tab @code{#f}
683 @tab Do not trust the @code{.ly} input.
684 @end multitable
685
686 @noindent
687 When LilyPond formatting is available through a web server, either the
688 @option{--safe} or the @option{--jail} option @b{MUST} be passed.  The
689 @option{--safe} option will prevent inline Scheme code from wreaking
690 havoc, e.g,
691
692 @quotation
693 @verbatim
694 #(s ystem "rm -rf /")  % too dangerous to write correctly
695 {
696   c4^$(ly:gulp-file "/etc/passwd") % malicious but not destructive
697 }
698 @end verbatim
699 @end quotation
700
701 The @option{-dsafe} option works by evaluating in-line Scheme
702 expressions in a special safe module.  This is derived from GUILE
703 @file{safe-r5rs} module, but also adds a number of functions of the
704 LilyPond API which are listed in @file{scm/safe-lily.scm}.
705
706 In addition, safe mode disallows @code{\include} directives and
707 disables the use of backslashes in @TeX{} strings.  It is also not
708 possible to import LilyPond variables into Scheme while in safe mode.
709
710 @option{-dsafe} does @emph{not} detect resource overuse, so it is still
711 possible to make the program hang indefinitely, for example by feeding
712 cyclic data structures into the backend.  Therefore, if using LilyPond
713 on a publicly accessible webserver, the process should be limited in
714 both CPU and memory usage.
715
716 Safe mode will prevent many useful LilyPond snippets from being
717 compiled.
718
719 The @option{--jail} is an even more secure alternative, but requires
720 more work to set up. See @ref{Basic command line options for LilyPond}.
721
722 @multitable @columnfractions .33 .16 .51
723 @item @code{separate-log-files}
724 @tab @code{#f}
725 @tab For input files @code{FILE1.ly}, @code{FILE2.ly}, etc. output log
726 data to files @code{FILE1.log}, @code{FILE2.log}@dots{}
727
728 @item @code{show-available-fonts}
729 @tab @code{#f}
730 @tab List available font names.
731
732 @item @code{strict-infinity-checking}
733 @tab @code{#f}
734 @tab Force a crash on encountering @code{Inf} and @code{NaN} floating
735 point exceptions.
736
737 @item @code{strip-output-dir}
738 @tab @code{#t}
739 @tab Don't use directories from input files while constructing output
740 file names.
741
742 @item @code{strokeadjust}
743 @tab @code{#f}
744 @tab Force PostScript stroke adjustment.  This option is mostly
745 relevant when a PDF is generated from PostScript output (stroke
746 adjustment is usually enabled automatically for low-resolution bitmap
747 devices).  Without this option, PDF previewers tend to produce widely
748 inconsistent stem widths at resolutions typical for screen display.  The
749 option does not noticeably affect print quality and causes large file
750 size increases in PDF files.
751
752 @item @code{svg-woff}
753 @tab @code{#f}
754 @tab Use woff font files in SVG backend.
755
756 @item @code{trace-memory-frequency}
757 @tab @code{#f}
758 @tab Record Scheme cell usage this many times per second.  Dump the
759 results to @code{FILE.stacks} and @code{FILE.graph}.
760
761 @item @code{trace-scheme-coverage}
762 @tab @code{#f}
763 @tab Record coverage of Scheme files in @code{FILE.cov}.
764
765 @item @code{verbose}
766 @tab @code{#f}
767 @tab Verbose output, i.e. loglevel at DEBUG (read-only).
768
769 @item @code{warning-as-error}
770 @tab @code{#f}
771 @tab Change all warning and @q{programming error} messages into errors.
772 @end multitable
773
774
775 @node Environment variables
776 @unnumberedsubsec Environment variables
777
778 @cindex LANG
779 @cindex LILYPOND_DATADIR
780
781 @command{lilypond} recognizes the following environment variables:
782 @table @code
783 @item LILYPOND_DATADIR
784 This specifies a directory where locale messages and
785 data files will be looked up by default.  The directory should contain
786 subdirectories called @file{ly/}, @file{ps/}, @file{tex/}, etc.
787
788 @item LANG
789 This selects the language for the warning messages.
790
791 @item LILYPOND_LOGLEVEL
792 The default loglevel. If LilyPond is called without an explicit loglevel
793 (i.e. no @option{--loglevel} command line option), this value is used.
794
795 @item LILYPOND_GC_YIELD
796 A variable, as a percentage, that tunes memory management
797 behavior.  A higher values means the program uses more memory, a
798 smaller value means more CPU time is used.  The default value is
799 @code{70}.
800
801 @end table
802
803
804 @node LilyPond in chroot jail
805 @unnumberedsubsec LilyPond in chroot jail
806
807 Setting up the server to run LilyPond in a chroot jail is a complicated
808 task.  The steps are listed below.  Examples in the steps are from
809 Ubuntu GNU/Linux, and may require the use of @code{sudo} as appropriate.
810
811 @itemize
812
813 @item Install the necessary packages: LilyPond, GhostScript, and ImageMagick.
814
815 @item Create a new user by the name of @code{lily}:
816
817 @example
818 adduser lily
819 @end example
820
821 @noindent
822 This will create a new group for the @code{lily} user as well, and a
823 home folder, @code{/home/lily}
824
825 @item In the home folder of the @code{lily} user create a file to use as a
826 separate filesystem:
827
828 @example
829 dd if=/dev/zero of=/home/lily/loopfile bs=1k count= 200000
830 @end example
831
832 @noindent
833 This example creates a 200MB file for use as the jail filesystem.
834
835 @item Create a loop device, make a file system and mount it, then create
836 a folder that can be written by the @code{lily} user:
837
838 @example
839 mkdir /mnt/lilyloop
840 losetup /dev/loop0 /home/lily/loopfile
841 mkfs -t ext3 /dev/loop0 200000
842 mount -t ext3 /dev/loop0 /mnt/lilyloop
843 mkdir /mnt/lilyloop/lilyhome
844 chown lily /mnt/lilyloop/lilyhome
845 @end example
846
847 @item In the configuration of the servers, the JAIL will be @code{/mnt/lilyloop}
848 and the DIR will be @code{/lilyhome}.
849
850 @item Create a big directory tree in the jail by copying the necessary files, as
851 shown in the sample script below.
852
853 You can use @code{sed} to create the necessary copy commands for a given
854 executable:
855
856 @example
857 for i in "/usr/local/lilypond/usr/bin/lilypond" "/bin/sh" "/usr/bin/;  \
858   do ldd $i | sed 's/.*=> \/\(.*\/\)\([^(]*\).*/mkdir -p \1 \&\&  \
859     cp -L \/\1\2 \1\2/' | sed 's/\t\/\(.*\/\)\(.*\) (.*)$/mkdir -p  \
860       \1 \&\& cp -L \/\1\2 \1\2/' | sed '/.*=>.*/d'; done
861 @end example
862
863 @end itemize
864
865 @subheading Example script for 32-bit Ubuntu 8.04
866
867 @example
868 #!/bin/sh
869 ## defaults set here
870
871 username=lily
872 home=/home
873 loopdevice=/dev/loop0
874 jaildir=/mnt/lilyloop
875 # the prefix (without the leading slash!)
876 lilyprefix=usr/local
877 # the directory where lilypond is installed on the system
878 lilydir=/$lilyprefix/lilypond/
879
880 userhome=$home/$username
881 loopfile=$userhome/loopfile
882 adduser $username
883 dd if=/dev/zero of=$loopfile bs=1k count=200000
884 mkdir $jaildir
885 losetup $loopdevice $loopfile
886 mkfs -t ext3 $loopdevice 200000
887 mount -t ext3 $loopdevice $jaildir
888 mkdir $jaildir/lilyhome
889 chown $username $jaildir/lilyhome
890 cd $jaildir
891
892 mkdir -p bin usr/bin usr/share usr/lib usr/share/fonts $lilyprefix tmp
893 chmod a+w tmp
894
895 cp -r -L $lilydir $lilyprefix
896 cp -L /bin/sh /bin/rm bin
897 cp -L /usr/bin/convert /usr/bin/gs usr/bin
898 cp -L /usr/share/fonts/truetype usr/share/fonts
899
900 # Now the library copying magic
901 for i in "$lilydir/usr/bin/lilypond" "$lilydir/usr/bin/guile" "/bin/sh"  \
902   "/bin/rm" "/usr/bin/gs" "/usr/bin/convert"; do ldd $i | sed 's/.*=>  \
903     \/\(.*\/\)\([^(]*\).*/mkdir -p \1 \&\& cp -L \/\1\2 \1\2/' | sed  \
904       's/\t\/\(.*\/\)\(.*\) (.*)$/mkdir -p \1 \&\& cp -L \/\1\2 \1\2/'  \
905         | sed '/.*=>.*/d'; done | sh -s
906
907 # The shared files for ghostscript...
908       cp -L -r /usr/share/ghostscript usr/share
909 # The shared files for ImageMagick
910       cp -L -r /usr/lib/ImageMagick* usr/lib
911
912 ### Now, assuming that you have test.ly in /mnt/lilyloop/lilyhome,
913 ### you should be able to run:
914 ### Note that /$lilyprefix/bin/lilypond is a script, which sets the
915 ### LD_LIBRARY_PATH - this is crucial
916       /$lilyprefix/bin/lilypond -jlily,lily,/mnt/lilyloop,/lilyhome test.ly
917 @end example
918
919 @c " keep quote signs balanced for context-sensitive editors
920
921 @node Error messages
922 @section Error messages
923
924 @cindex error messages
925 Different error messages can appear while compiling a file:
926
927 @table @emph
928
929 @item Warning
930 @cindex warning
931 Something looks suspect.  If you are requesting something out of the
932 ordinary then you will understand the message, and can ignore it.
933 However, warnings usually indicate that something is wrong with the
934 input file.
935
936 @item Error
937 @cindex error
938 Something is definitely wrong.  The current processing step (parsing,
939 interpreting, or formatting) will be finished, but the next step will
940 be skipped.
941
942 @item Fatal error
943 @cindex fatal error
944 Something is definitely wrong, and LilyPond cannot continue.  This
945 happens rarely.  The most usual cause is misinstalled fonts.
946
947 @item Scheme error
948 @cindex trace, Scheme
949 @cindex call trace
950 @cindex Scheme error
951 Errors that occur while executing Scheme code are caught by the Scheme
952 interpreter.  If running with the verbose option (@option{-V} or
953 @option{--verbose}) then a call trace of the offending
954 function call is printed.
955
956 @item Programming error
957 @cindex Programming error
958 There was some internal inconsistency.  These error messages are
959 intended to help the programmers and debuggers.  Usually, they can be
960 ignored.  Sometimes, they come in such big quantities that they obscure
961 other output.
962
963 @item Aborted (core dumped)
964 @cindex Aborted (core dumped)
965 This signals a serious programming error that caused the program to
966 crash.  Such errors are considered critical.  If you stumble on one,
967 send a bug-report.
968 @end table
969
970 @cindex errors, message format
971 If warnings and errors can be linked to some part of the input file,
972 then error messages have the following form
973
974 @example
975 @var{filename}:@var{lineno}:@var{columnno}: @var{message}
976 @var{offending input line}
977 @end example
978
979 A line-break is inserted in the offending line to indicate the column
980 where the error was found.  For example,
981
982 @example
983 test.ly:2:19: error: not a duration: 5
984   @{ c'4 e'
985            5 g' @}
986 @end example
987
988 These locations are LilyPond's best guess about where the warning or
989 error occurred, but (by their very nature) warnings and errors occur
990 when something unexpected happens.  If you can't see an error in the
991 indicated line of your input file, try checking one or two lines
992 above the indicated position.
993
994 Please note that diagnostics can be triggered at any point during the
995 many stages of processing.  For example if there are parts of the input
996 that are processed multiple times (i.e. in midi and layout output), or
997 if the same music variable is used in multiple contexts the same message
998 may appear several times.  Diagnostics produced at a @q{late} stage (i.e
999 bar checks) might also be issued multiple times.
1000
1001 More information about errors is given in @ref{Common errors}.
1002
1003
1004 @node Common errors
1005 @section Common errors
1006
1007 The error conditions described below occur often, yet the cause
1008 is not obvious or easily found.  Once seen and understood, they
1009 are easily handled.
1010
1011
1012 @menu
1013 * Music runs off the page::
1014 * An extra staff appears::
1015 * Error message Unbound variable %::
1016 * Error message FT_Get_Glyph_Name::
1017 * Warning staff affinities should only decrease::
1018 * Error message unexpected new::
1019 * Warning this voice needs a voiceXx or shiftXx setting::
1020 @end menu
1021
1022 @node Music runs off the page
1023 @unnumberedsubsec Music runs off the page
1024
1025 Music running off the page over the right margin or appearing
1026 unduly compressed is almost always due to entering an incorrect
1027 duration on a note, causing the final note in a measure to extend
1028 over the bar line.  It is not invalid if the final note in a
1029 measure does not end on the automatically entered bar line, as the
1030 note is simply assumed to carry over into the next measure.  But
1031 if a long sequence of such carry-over measures occurs the music
1032 can appear compressed or may flow off the page because automatic
1033 line breaks can be inserted only at the end of complete measures,
1034 i.e., where all notes end before or at the end of the measure.
1035
1036 @warning{An incorrect duration can cause line breaks to be
1037 inhibited, leading to a line of highly compressed music or
1038 music which flows off the page.}
1039
1040 The incorrect duration can be found easily if bar checks are used,
1041 see @ruser{Bar and bar number checks}.
1042
1043 If you actually intend to have a series of such carry-over measures
1044 you will need to insert an invisible bar line where you want the
1045 line to break.  For details, see @ruser{Bar lines}.
1046
1047
1048 @node An extra staff appears
1049 @unnumberedsubsec An extra staff appears
1050
1051 If contexts are not created explicitly with @code{\new} or
1052 @code{\context}, they will be silently created as soon as a
1053 command is encountered which cannot be applied to an existing
1054 context.  In simple scores the automatic creation of contexts is
1055 useful, and most of the examples in the LilyPond manuals take
1056 advantage of this simplification.  But occasionally the silent
1057 creation of contexts can give rise to unexpected new staves or
1058 scores.  For example, it might be expected that the following code
1059 would cause all note heads within the following staff to be
1060 colored red, but in fact it results in two staves with the note
1061 heads remaining the default black in the lower staff.
1062
1063 @lilypond[quote,verbatim,relative=2]
1064 \override Staff.NoteHead.color = #red
1065 \new Staff { a }
1066 @end lilypond
1067
1068 This is because a @code{Staff} context does not exist when the
1069 override is processed, so one is implicitly created and the override
1070 is applied to it, but then the @code{\new Staff} command creates
1071 another, separate, staff into which the notes are placed.  The
1072 correct code to color all note heads red is
1073
1074 @lilypond[quote,verbatim,relative=2]
1075 \new Staff {
1076   \override Staff.NoteHead.color = #red
1077   a
1078 }
1079 @end lilypond
1080
1081 @node Error message Unbound variable %
1082 @unnumberedsubsec Error message Unbound variable %
1083
1084 This error message will appear at the bottom of the console
1085 output or log file together with a @qq{GUILE signalled an error @dots{}}
1086 message every time a Scheme routine is called which (invalidly)
1087 contains a @emph{LilyPond} rather than a @emph{Scheme} comment.
1088
1089 LilyPond comments begin with a percent sign, (@code{%}), and must
1090 not be used within Scheme routines.  Scheme comments begin with a
1091 semi-colon, (@code{;}).
1092
1093 @node Error message FT_Get_Glyph_Name
1094 @unnumberedsubsec Error message FT_Get_Glyph_Name
1095
1096 This error messages appears in the console output or log file if
1097 an input file contains a non-ASCII character and was not saved in
1098 UTF-8 encoding.  For details, see @ruser{Text encoding}.
1099
1100
1101 @node Warning staff affinities should only decrease
1102 @unnumberedsubsec Warning staff affinities should only decrease
1103
1104 This warning can appear if there are no staves in the printed
1105 output, for example if there are just a @code{ChordName} context
1106 and a @code{Lyrics} context as in a lead sheet.  The warning
1107 messages can be avoided by making one of the contexts behave as a
1108 staff by inserting
1109
1110 @example
1111 \override VerticalAxisGroup.staff-affinity = ##f
1112 @end example
1113
1114 @noindent
1115 at its start.  For details, see @qq{Spacing of non-staff lines} in
1116 @ruser{Flexible vertical spacing within systems}.
1117
1118
1119 @node Error message unexpected new
1120 @unnumberedsubsec Error message unexpected @code{@bs{}new}
1121
1122 A @code{\score} block must contain a @emph{single} music expression.
1123 If instead it contains several @code{\new Staff},
1124 @code{\new StaffGroup} or similar contexts introduced with @code{\new}
1125 without them being enclosed in either curly brackets,
1126 @code{@{ @dots{} @}}, or double angle brackets, @code{<< @dots{} >>},
1127 like this:
1128
1129 @example
1130 \score @{
1131   % Invalid! Generates error: syntax error, unexpected \new
1132   \new Staff @{ @dots{} @}
1133   \new Staff @{ @dots{} @}
1134 @}
1135 @end example
1136
1137 @noindent
1138 the error message will be produced.
1139
1140 To avoid the error, enclose all the @code{\new} statements in
1141 curly or double angle brackets.
1142
1143 Using curly brackets will introduce the @code{\new} statements
1144 sequentially:
1145
1146 @lilypond[quote,verbatim]
1147 \score {
1148   {
1149     \new Staff { a' a' a' a' }
1150     \new Staff { g' g' g' g' }
1151   }
1152 }
1153 @end lilypond
1154
1155 @noindent
1156 but more likely you should be using double angle brackets so the new
1157 staves are introduced in parallel, i.e. simultaneously:
1158
1159 @lilypond[quote,verbatim]
1160 \score {
1161   <<
1162     \new Staff { a' a' a' a' }
1163     \new Staff { g' g' g' g' }
1164   >>
1165 }
1166 @end lilypond
1167
1168 @node Warning this voice needs a voiceXx or shiftXx setting
1169 @unnumberedsubsec Warning this voice needs a @code{@bs{}voiceXx}
1170  or @code{@bs{}shiftXx} setting
1171
1172 If notes from two different voices with stems in the same direction
1173 occur at the same musical moment, but the voices have no
1174 voice-specific shifts specified, the warning message
1175 @samp{warning: this voice needs a \voiceXx or \shiftXx setting} will appear
1176 when compiling the LilyPond file.  This warning will appear even when
1177 the notes have no visible stems, e.g. whole notes, if the stems for
1178 shorter notes at the same pitch would be in the same direction.
1179
1180 Remember that the stem direction depends on the position of the
1181 note on the staff unless the stem direction is specified, for example
1182 by using @code{\voiceOne}, etc.  In this case the warning will appear
1183 only when the stems happen to be in the same direction, i.e. when the
1184 notes are in the same half of the staff.
1185
1186 By placing the notes in voices with stem directions and shifts
1187 specified, for example by using @code{\voiceOne}, etc., these warnings
1188 may be avoided.
1189
1190 Notes in higher numbered voices, @code{\voiceThree} etc., are
1191 automatically shifted to avoid clashing note columns.  This causes a
1192 visible shift for notes with stems, but whole notes are not visibly
1193 shifted unless an actual clash of the note heads occurs, or when the
1194 voices cross over from their natural order (when @code{\voiceThree}
1195 is higher than @code{\voiceOne}, etc.)
1196
1197 @seealso
1198 @rlearning{Explicitly instantiating voices},
1199 @rlearning{Real music example},
1200 @ruser{Single-staff polyphony},
1201 @ruser{Collision resolution}.