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