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