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