]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/usage/running.itely
Merge remote-tracking branch 'origin' into HEAD
[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.15.18"
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 * Command line options for lilypond::
57 * Environment variables::
58 * LilyPond in chroot jail::
59 @end menu
60
61 @node Invoking lilypond
62 @unnumberedsubsec Invoking @command{lilypond}
63
64 The @command{lilypond} executable may be called as follows from
65 the command line.
66
67 @example
68 lilypond [@var{option}]@dots{} @var{file}@dots{}
69 @end example
70
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 Standard shell commands
101
102 If your shell (i.e. command window) supports normal redirects,
103 then you might find it useful to use the following commands to
104 redirect console output to a file:
105
106 @itemize
107
108 @item
109 @code{lilypond file.ly 1>stdout.log} to redirect normal output
110
111 @item
112 @code{lilypond file.ly 2>stderr.log} to redirect error messages
113
114 @item
115 @code{lilypond file.ly &>all.log} to redirect all output
116
117 @end itemize
118
119 Consult the documentation for your shell to see if it supports these
120 options, or if the syntax is different.  Note that these are shell
121 commands and have nothing to do with lilypond.
122
123
124 @node Command line options for lilypond
125 @unnumberedsubsec Command line options for @command{lilypond}
126
127 @cindex Invoking @command{lilypond}
128 @cindex command line options for @command{lilypond}
129 @cindex options, command line
130 @cindex switches
131
132 The following options are supported:
133
134 @table @code
135
136 @item -d,--define-default=@var{var}=@var{val}
137 This sets the internal program option @var{var} to the Scheme value
138 @var{val}.  If @var{val} is not supplied, then @var{#t} is used.  To
139 switch off an option, @code{no-} may be prefixed to @var{var}, e.g.
140
141 @cindex point and click, command line
142
143 @example
144 -dno-point-and-click
145 @end example
146
147 @noindent
148 is the same as
149 @example
150 -dpoint-and-click=#f
151 @end example
152
153 The following options are supported:
154
155 @cindex help, command line
156
157 @table @code
158
159 @item help
160 Running @code{lilypond -dhelp} will print all of the @option{-d} options
161 available.
162
163 @cindex paper-size, command line
164
165 @item paper-size
166 This option sets the default paper-size,
167 @example
168 -dpaper-size=\"letter\"
169 @end example
170
171 @noindent
172 Note that the string must be enclosed in escaped quotes ( @code{\"} ).
173 @c Match " in previous line to help context-sensitive editors
174
175 @cindex safe, command line
176
177 @item safe
178 Do not trust the @code{.ly} input.
179
180 When LilyPond formatting is available through a web server, either the
181 @option{--safe} or the @option{--jail} option @b{MUST} be passed.  The
182 @option{--safe} option will prevent inline Scheme code from wreaking
183 havoc, for example
184
185 @quotation
186 @verbatim
187 #(system "rm -rf /")
188 {
189   c4^$(ly:gulp-file "/etc/passwd")
190 }
191 @end verbatim
192 @end quotation
193
194 The @option{-dsafe} option works by evaluating in-line Scheme
195 expressions in a special safe module.  This safe module is derived from
196 GUILE @file{safe-r5rs} module, but adds a number of functions of the
197 LilyPond API.  These functions are listed in @file{scm/safe-lily.scm}.
198
199 In addition, safe mode disallows @code{\include} directives and
200 disables the use of backslashes in @TeX{} strings.
201
202 In safe mode, it is not possible to import LilyPond variables into
203 Scheme.
204
205 @option{-dsafe} does @emph{not} detect resource overuse.  It is still
206 possible to make the program hang indefinitely, for example by feeding
207 cyclic data structures into the backend.  Therefore, if using LilyPond
208 on a publicly accessible webserver, the process should be limited in
209 both CPU and memory usage.
210
211 Safe mode will prevent many useful LilyPond snippets from being
212 compiled.  The @option{--jail} is a more secure alternative, but
213 requires more work to set up.
214
215 @cindex output format, setting
216
217 @item backend
218 the output format to use for the backend.  Choices for @code{format}
219 are:
220
221 @table @code
222 @item ps
223
224 @cindex PostScript output
225
226 for PostScript.
227
228 Postscript files include TTF, Type1 and OTF fonts.  No subsetting of
229 these fonts is done.  When using oriental character sets, this can lead
230 to huge files.
231
232 @item eps
233
234 @cindex Postscript, encapsulated
235 @cindex EPS (Encapsulated PostScript)
236
237 for encapsulated PostScript.  This dumps every page (system) as a
238 separate @file{EPS} file, without fonts, and as one collated @file{EPS}
239 file with all pages (systems) including fonts.
240
241 This mode is used by default by @command{lilypond-book}.
242
243 @item svg
244
245 @cindex SVG (Scalable Vector Graphics)
246
247 for SVG (Scalable Vector Graphics).
248
249 This creates a single SVG file, without embedded fonts, for every page
250 of output.  It is recommended to install the Century Schoolbook fonts,
251 included with your LilyPond installation, for optimal rendering.  Under
252 UNIX, simply copy these fonts from the LilyPond directory (typically
253 @file{/usr/share/lilypond/VERSION/fonts/otf/}) to @file{~/.fonts/}.  The
254 SVG output should be compatible with any SVG editor or user agent.
255
256 @item scm
257
258 @cindex Scheme dump
259 @cindex output, Scheme dump
260
261 for a dump of the raw, internal Scheme-based drawing commands.
262
263 @item null
264 do not output a printed score; has the same effect as
265 @option{-dno-print-pages}.
266
267 @end table
268
269 Example: @code{lilypond -dbackend=svg @var{filename}.ly}
270
271 @item preview
272
273 @cindex preview, command line
274
275 This option is supported by all backends; @code{pdf}, @code{png},
276 @code{ps}, @code{eps} and @code{svg}, but not @code{scm}.  It generates
277 an output file, in the form @code{myFile.preview.extension}, containing
278 the titles and the first system of music.  If @code{\book} or
279 @code{\bookpart} blocks are used, the titles of @code{\book},
280 @code{\bookpart} or @code{\score} will appear in the output, including
281 the first system of every @code{\score} block if the @code{\paper}
282 variable @code{print-all-headers} is set to @code{#t}.
283
284 To suppress the usual output, use the @option{-dprint-pages} or
285 @option{-dno-print-pages} options according to your requirements.
286
287 @item gui
288 Runs silently and redirect all output to a log file.
289
290 Note to Windows users: By default @code{lilypond.exe} outputs all
291 progress information to the command window, @code{lilypond-windows.exe}
292 does not and returns a prompt, with no progress information, immediately
293 at the command line.  The @option{-dgui} option can be used in this case
294 to redirect output to a log file.
295
296 @item print-pages
297 Generate the full pages, the default.  @option{-dno-print-pages} is
298 useful in combination with @option{-dpreview}.
299
300 @end table
301
302 @cindex Scheme, expression evaluation
303 @cindex expression evaluation, Scheme
304
305 @item -e,--evaluate=@var{expr}
306 Evaluate the Scheme @var{expr} before parsing any @file{.ly} files.
307 Multiple @option{-e} options may be given, they will be evaluated
308 sequentially.
309
310 The expression will be evaluated in the @code{guile-user} module, so
311 if you want to use definitions in @var{expr}, use
312
313 @example
314 lilypond -e '(define-public a 42)'
315 @end example
316
317 @noindent
318 on the command-line, and include
319
320 @example
321 #(use-modules (guile-user))
322 @end example
323
324 @noindent
325 at the top of the @code{.ly} file.
326
327 @warning{Windows users must use double quotes instead of single quotes.}
328
329 @cindex output, format
330 @cindex format, output
331
332 @item -f,--format=@var{format}
333 which formats should be written.  Choices for @code{format} are
334 @code{ps}, @code{pdf}, and @code{png}.
335
336 Example: @code{lilypond -fpng @var{filename}.ly}
337
338 @item -h,--help
339 Show a summary of usage.
340
341 @item -H,--header=@var{FIELD}
342 Dump a header field to file @file{BASENAME.@var{FIELD}}.
343
344 @item -i,--init=@var{file}
345 Set init file to @var{file} (default: @file{init.ly}).
346
347 @cindex file searching
348 @cindex search path
349
350 @item -I, --include=@var{directory}
351 Add @var{directory} to the search path for input files.
352
353 Multiple -I options may be given.  The search will start in the first
354 defined directory, and if the file to be included is not found the
355 search will continue in subsequent directories.
356
357 @cindex chroot jail, running inside
358
359 @item -j,--jail=@var{user},@var{group},@var{jail},@var{dir}
360 Run @command{lilypond} in a chroot jail.
361
362 The @option{--jail} option provides a more flexible alternative to
363 @option{--safe} when LilyPond formatting is available through a web
364 server or whenever LilyPond executes externally provided
365 sources.
366
367 The @option{--jail} option works by changing the root of
368 @command{lilypond} to @var{jail} just before starting the actual
369 compilation process.  The user and group are then changed to match those
370 provided, and the current directory is changed to @var{dir}.  This setup
371 guarantees that it is not possible (at least in theory) to escape from
372 the jail.  Note that for @option{--jail} to work @command{lilypond} must
373 be run as root, which is usually accomplished in a safe way using
374 @command{sudo}.
375
376 Setting up a jail is a slightly delicate matter, as we must be sure that
377 LilyPond is able to find whatever it needs to compile the source
378 @emph{inside the jail}.  A typical setup comprises the following items:
379
380 @table @asis
381
382 @item Setting up a separate filesystem
383 A separate filesystem should be created for LilyPond, so that it can be
384 mounted with safe options such as @code{noexec}, @code{nodev}, and
385 @code{nosuid}.  In this way, it is impossible to run executables or to
386 write directly to a device from LilyPond.  If you do not want to create a
387 separate partition, just create a file of reasonable size and use it to
388 mount a loop device.  A separate filesystem also guarantees that LilyPond
389 cannot write more space than it is allowed.
390
391 @item Setting up a separate user
392 A separate user and group (say, @code{lily}/@code{lily}) with low
393 privileges should be used to run LilyPond inside the jail.  There should
394 be a single directory writable by this user, which should be passed in
395 @var{dir}.
396
397 @item Preparing the jail
398 LilyPond needs to read a number of files while running.  All these files
399 are to be copied into the jail, under the same path they appear in the
400 real root filesystem.  The entire content of the LilyPond installation
401 (e.g., @file{/usr/share/lilypond}) should be copied.
402
403 If problems arise, the simplest way to trace them down is to run
404 LilyPond using @command{strace}, which will allow you to determine which
405 files are missing.
406
407 @item Running LilyPond
408 In a jail mounted with @code{noexec} it is impossible to execute any
409 external program.  Therefore LilyPond must be run with a backend that
410 does not require any such program.  As we already mentioned, it must be
411 also run with superuser privileges (which, of course, it will lose
412 immediately), possibly using @command{sudo}.  It is a good idea to limit
413 the number of seconds of CPU time LilyPond can use (e.g., using
414 @command{ulimit@tie{}-t}), and, if your operating system supports it,
415 the amount of memory that can be allocated.
416
417 @end table
418
419 @cindex loglevel
420 @cindex output, verbosity
421
422 @item -l,--loglevel=@var{LEVEL}
423 Set the verbosity of the console output to @var{LEVEL}. Possible values
424 are:
425
426 @table @code
427
428 @item NONE
429 No output at all, not even error messages.
430
431 @item ERROR
432 Only error messages, no warnings or progress messages.
433
434 @item WARN
435 Warnings and error messages, no progress.
436
437 @item BASIC_PROGRESS
438 Basic progress messages (success), warnings and errors.
439
440 @item PROGRESS
441 All progress messages, warnings and errors.
442
443 @item INFO (default)
444 Progress messages, warnings, errors and further execution information.
445
446 @item DEBUG
447 All possible messages, including verbose debug output.
448
449 @end table
450
451 @cindex directory, redirect output
452 @cindex output, setting filename
453 @cindex output, directory
454
455 @item -o,--output=@var{FILE} or @var{FOLDER}
456 Set the default output file to @var{FILE} or, if a folder with that name
457 exists, direct the output to @var{FOLDER}, taking the file name from the
458 input file.  The appropriate suffix will be added (e.g. @code{.pdf} for
459 pdf) in both cases.
460
461 @cindex PS (Postscript), output
462 @cindex Postscript (PS), output
463 @cindex output, PS (Postscript)
464
465 @item --ps
466 Generate PostScript.
467
468 @cindex PNG (Portable Network Graphics), output
469 @cindex output, PNG (Portable Network Graphics)
470
471 @item --png
472 Generate pictures of each page, in PNG format.  This implies
473 @option{--ps}.  The resolution in DPI of the image may be set with
474 @example
475 -dresolution=110
476 @end example
477
478 @cindex PDF (Portable Document Format), output
479 @cindex output, PDF (Portable Document Format)
480
481 @item --pdf
482 Generate PDF.  This implies @option{--ps}.
483
484 @item -v,--version
485 Show version information.
486
487 @item -V,--verbose
488 Be verbose: show full paths of all files read, and give timing
489 information.
490
491 @item -w,--warranty
492 Show the warranty with which GNU LilyPond comes.  (It comes with
493 @strong{NO WARRANTY}!)
494
495 @end table
496
497
498 @node Environment variables
499 @unnumberedsubsec Environment variables
500
501
502 @cindex LANG
503 @cindex LILYPOND_DATADIR
504
505 @command{lilypond} recognizes the following environment variables:
506 @table @code
507 @item LILYPOND_DATADIR
508 This specifies a directory where locale messages and
509 data files will be looked up by default.  The directory should contain
510 subdirectories called @file{ly/}, @file{ps/}, @file{tex/}, etc.
511
512 @item LANG
513 This selects the language for the warning messages.
514
515 @item LILYPOND_LOGLEVEL
516 The default loglevel. If LilyPond is called without an explicit loglevel (i.e.
517 no @option{--loglevel} command line option), this value is used.
518
519 @item LILYPOND_GC_YIELD
520 A variable, as a percentage, that tunes memory management
521 behavior.  A higher values means the program uses more memory, a
522 smaller value means more CPU time is used.  The default value is
523 @code{70}.
524
525 @end table
526
527
528 @node LilyPond in chroot jail
529 @unnumberedsubsec LilyPond in chroot jail
530
531 Setting up the server to run LilyPond in a chroot jail is a complicated
532 task.  The steps are listed below.  Examples in the steps are from
533 Ubuntu Linux, and may require the use of @code{sudo} as appropriate.
534
535 @itemize
536
537 @item Install the necessary packages: LilyPond, GhostScript, and ImageMagick.
538
539 @item Create a new user by the name of @code{lily}:
540
541 @example
542 adduser lily
543 @end example
544
545 @noindent
546 This will create a new group for the @code{lily} user as well, and a
547 home folder, @code{/home/lily}
548
549 @item In the home folder of the @code{lily} user create a file to use as a
550 separate filesystem:
551
552 @example
553 dd if=/dev/zero of=/home/lily/loopfile bs=1k count= 200000
554 @end example
555
556 @noindent
557 This example creates a 200MB file for use as the jail filesystem.
558
559 @item Create a loop device, make a file system and mount it, then create
560 a folder that can be written by the @code{lily} user:
561
562 @example
563 mkdir /mnt/lilyloop
564 losetup /dev/loop0 /home/lily/loopfile
565 mkfs -t ext3 /dev/loop0 200000
566 mount -t ext3 /dev/loop0 /mnt/lilyloop
567 mkdir /mnt/lilyloop/lilyhome
568 chown lily /mnt/lilyloop/lilyhome
569 @end example
570
571 @item In the configuration of the servers, the JAIL will be @code{/mnt/lilyloop}
572 and the DIR will be @code{/lilyhome}.
573
574 @item Create a big directory tree in the jail by copying the necessary files, as
575 shown in the sample script below.
576
577 You can use @code{sed} to create the necessary copy commands for a given
578 executable:
579
580 @example
581 for i in "/usr/local/lilypond/usr/bin/lilypond" "/bin/sh" "/usr/bin/;  \
582   do ldd $i | sed 's/.*=> \/\(.*\/\)\([^(]*\).*/mkdir -p \1 \&\&  \
583     cp -L \/\1\2 \1\2/' | sed 's/\t\/\(.*\/\)\(.*\) (.*)$/mkdir -p  \
584       \1 \&\& cp -L \/\1\2 \1\2/' | sed '/.*=>.*/d'; done
585 @end example
586
587 @end itemize
588
589 @subheading Example script for 32-bit Ubuntu 8.04
590
591 @example
592 #!/bin/sh
593 ## defaults set here
594
595 username=lily
596 home=/home
597 loopdevice=/dev/loop0
598 jaildir=/mnt/lilyloop
599 # the prefix (without the leading slash!)
600 lilyprefix=usr/local
601 # the directory where lilypond is installed on the system
602 lilydir=/$lilyprefix/lilypond/
603
604 userhome=$home/$username
605 loopfile=$userhome/loopfile
606 adduser $username
607 dd if=/dev/zero of=$loopfile bs=1k count=200000
608 mkdir $jaildir
609 losetup $loopdevice $loopfile
610 mkfs -t ext3 $loopdevice 200000
611 mount -t ext3 $loopdevice $jaildir
612 mkdir $jaildir/lilyhome
613 chown $username $jaildir/lilyhome
614 cd $jaildir
615
616 mkdir -p bin usr/bin usr/share usr/lib usr/share/fonts $lilyprefix tmp
617 chmod a+w tmp
618
619 cp -r -L $lilydir $lilyprefix
620 cp -L /bin/sh /bin/rm bin
621 cp -L /usr/bin/convert /usr/bin/gs usr/bin
622 cp -L /usr/share/fonts/truetype usr/share/fonts
623
624 # Now the library copying magic
625 for i in "$lilydir/usr/bin/lilypond" "$lilydir/usr/bin/guile" "/bin/sh"  \
626   "/bin/rm" "/usr/bin/gs" "/usr/bin/convert"; do ldd $i | sed 's/.*=>  \
627     \/\(.*\/\)\([^(]*\).*/mkdir -p \1 \&\& cp -L \/\1\2 \1\2/' | sed  \
628       's/\t\/\(.*\/\)\(.*\) (.*)$/mkdir -p \1 \&\& cp -L \/\1\2 \1\2/'  \
629         | sed '/.*=>.*/d'; done | sh -s
630
631 # The shared files for ghostscript...
632       cp -L -r /usr/share/ghostscript usr/share
633 # The shared files for ImageMagick
634       cp -L -r /usr/lib/ImageMagick* usr/lib
635
636 ### Now, assuming that you have test.ly in /mnt/lilyloop/lilyhome,
637 ### you should be able to run:
638 ### Note that /$lilyprefix/bin/lilypond is a script, which sets the
639 ### LD_LIBRARY_PATH - this is crucial
640       /$lilyprefix/bin/lilypond -jlily,lily,/mnt/lilyloop,/lilyhome test.ly
641 @end example
642
643 @c " keep quote signs balanced for context-sensitive editors
644
645 @node Error messages
646 @section Error messages
647
648 @cindex error messages
649 Different error messages can appear while compiling a file:
650
651 @table @emph
652
653 @item Warning
654 @cindex warning
655 Something looks suspect.  If you are requesting something out of the
656 ordinary then you will understand the message, and can ignore it.
657 However, warnings usually indicate that something is wrong with the
658 input file.
659
660 @item Error
661 @cindex error
662 Something is definitely wrong.  The current processing step (parsing,
663 interpreting, or formatting) will be finished, but the next step will
664 be skipped.
665
666 @item Fatal error
667 @cindex fatal error
668 Something is definitely wrong, and LilyPond cannot continue.  This
669 happens rarely.  The most usual cause is misinstalled fonts.
670
671 @item Scheme error
672 @cindex trace, Scheme
673 @cindex call trace
674 @cindex Scheme error
675 Errors that occur while executing Scheme code are caught by the Scheme
676 interpreter.  If running with the verbose option (@option{-V} or
677 @option{--verbose}) then a call trace of the offending
678 function call is printed.
679
680 @item Programming error
681 @cindex Programming error
682 There was some internal inconsistency.  These error messages are
683 intended to help the programmers and debuggers.  Usually, they can be
684 ignored.  Sometimes, they come in such big quantities that they obscure
685 other output.
686
687 @item Aborted (core dumped)
688 @cindex Aborted (core dumped)
689 This signals a serious programming error that caused the program to
690 crash.  Such errors are considered critical.  If you stumble on one,
691 send a bug-report.
692 @end table
693
694 @cindex errors, message format
695 If warnings and errors can be linked to some part of the input file,
696 then error messages have the following form
697
698 @example
699 @var{filename}:@var{lineno}:@var{columnno}: @var{message}
700 @var{offending input line}
701 @end example
702
703 A line-break is inserted in the offending line to indicate the column
704 where the error was found.  For example,
705
706 @example
707 test.ly:2:19: error: not a duration: 5
708   @{ c'4 e'
709            5 g' @}
710 @end example
711
712 These locations are LilyPond's best guess about where the warning or
713 error occurred, but (by their very nature) warnings and errors occur
714 when something unexpected happens.  If you can't see an error in the
715 indicated line of your input file, try checking one or two lines
716 above the indicated position.
717
718 More information about errors is given in @ref{Common errors}.
719
720
721 @node Common errors
722 @section Common errors
723
724 The error conditions described below occur often, yet the cause
725 is not obvious or easily found.  Once seen and understood, they
726 are easily handled.
727
728
729 @menu
730 * Music runs off the page::
731 * An extra staff appears::
732 * Apparent error in ../ly/init.ly::
733 * Error message Unbound variable %::
734 * Error message FT_Get_Glyph_Name::
735 * Warning staff affinities should only decrease::
736 @end menu
737
738 @node Music runs off the page
739 @unnumberedsubsec Music runs off the page
740
741 Music running off the page over the right margin or appearing
742 unduly compressed is almost always due to entering an incorrect
743 duration on a note, causing the final note in a measure to extend
744 over the bar line.  It is not invalid if the final note in a
745 measure does not end on the automatically entered bar line, as the
746 note is simply assumed to carry over into the next measure.  But
747 if a long sequence of such carry-over measures occurs the music
748 can appear compressed or may flow off the page because automatic
749 line breaks can be inserted only at the end of complete measures,
750 i.e., where all notes end before or at the end of the measure.
751
752 @warning{An incorrect duration can cause line breaks to be
753 inhibited, leading to a line of highly compressed music or
754 music which flows off the page.}
755
756 The incorrect duration can be found easily if bar checks are used,
757 see @ruser{Bar and bar number checks}.
758
759 If you actually intend to have a series of such carry-over measures
760 you will need to insert an invisible bar line where you want the
761 line to break.  For details, see @ruser{Bar lines}.
762
763
764 @node An extra staff appears
765 @unnumberedsubsec An extra staff appears
766
767 If contexts are not created explicitly with @code{\new} or
768 @code{\context}, they will be silently created as soon as a
769 command is encountered which cannot be applied to an existing
770 context.  In simple scores the automatic creation of contexts is
771 useful, and most of the examples in the LilyPond manuals take
772 advantage of this simplification.  But occasionally the silent
773 creation of contexts can give rise to unexpected new staves or
774 scores.  For example, it might be expected that the following code
775 would cause all note heads within the following staff to be
776 colored red, but in fact it results in two staves with the note
777 heads remaining the default black in the lower staff.
778
779 @lilypond[quote,verbatim,relative=2]
780 \override Staff.NoteHead #'color = #red
781 \new Staff { a }
782 @end lilypond
783
784 This is because a @code{Staff} context does not exist when the
785 override is processed, so one is implicitly created and the override
786 is applied to it, but then the @code{\new Staff} command creates
787 another, separate, staff into which the notes are placed.  The
788 correct code to color all note heads red is
789
790 @lilypond[quote,verbatim,relative=2]
791 \new Staff {
792   \override Staff.NoteHead #'color = #red
793   a
794 }
795 @end lilypond
796
797 As a second example, if a @code{\relative} command is placed inside
798 a @code{\repeat} command, two staves result, the second offset from
799 the first, because the @code{\repeat} command generates two
800 @code{\relative} blocks, which each implicitly create @code{Staff}
801 and @code{Voice} blocks.
802
803 @lilypond[quote,verbatim]
804 \repeat unfold 2 {
805   \relative c' { c4 d e f }
806 }
807 @end lilypond
808
809 Explicitly instantiating the @code{Voice} context fixes the
810 problem:
811
812 @lilypond[quote,verbatim]
813 \new Voice {
814   \repeat unfold 2 {
815     \relative c' { c4 d e f }
816   }
817 }
818 @end lilypond
819
820
821 @node Apparent error in ../ly/init.ly
822 @unnumberedsubsec Apparent error in @code{../ly/init.ly}
823
824 Various obscure error messages may appear about syntax errors in
825 @file{../ly/init.ly} if the input file is not correctly formed,
826 for example, if it does not contain correctly
827 matched braces or quote signs.
828
829 The most common error is a missing brace, (@code{@}}), at the end of
830 a @code{score} block.  Here the solution is obvious: check the
831 @code{score} block is correctly terminated.  The correct structure
832 of an input file is described in @rlearning{How LilyPond input files work}.
833 Using an editor which automatically highlights matching brackets and
834 braces is helpful to avoid such errors.
835
836 A second common cause is no white space between the last syllable
837 of a lyrics block and the terminating brace, (@code{@}}).  Without
838 this separation the brace is taken to be part of the syllable.  It
839 is always advisable to ensure there is white space before and after
840 @emph{every} brace.  For the importance of this when using lyrics,
841 see @ruser{Entering lyrics}.
842
843 This error message can also appear if a terminating quote sign,
844 (@code{"}), is omitted.  In this case an accompanying error message
845 @c keep "-matching straight in fancy editors
846 should give a line number close to the line in error.  The
847 mismatched quote will usually be on the line one or two above.
848
849 @node Error message Unbound variable %
850 @unnumberedsubsec Error message Unbound variable %
851
852 This error message will appear at the bottom of the console
853 output or log file together with a @qq{GUILE signalled an error @dots{}}
854 message every time a Scheme routine is called which (invalidly)
855 contains a @emph{LilyPond} rather than a @emph{Scheme} comment.
856
857 LilyPond comments begin with a percent sign, (@code{%}), and must
858 not be used within Scheme routines.  Scheme comments begin with a
859 semi-colon, (@code{;}).
860
861 @node Error message FT_Get_Glyph_Name
862 @unnumberedsubsec Error message FT_Get_Glyph_Name
863
864 This error messages appears in the console output or log file if
865 an input file contains a non-ASCII character and was not saved in
866 UTF-8 encoding.  For details, see @ruser{Text encoding}.
867
868
869 @node Warning staff affinities should only decrease
870 @unnumberedsubsec Warning staff affinities should only decrease
871 This warning can appear if there are no staves in the printed
872 output, for example if there are just a @code{ChordName} context
873 and a @code{Lyrics} context as in a lead sheet.  The warning
874 messages can be avoided by making one of the contexts behave as a
875 staff by inserting
876
877 @example
878 \override VerticalAxisGroup #'staff-affinity = ##f
879 @end example
880
881 @noindent
882 at its start.  For details, see @qq{Spacing of non-staff lines} in
883 @ruser{Flexible vertical spacing within systems}.