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