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