]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/application/running.itely
Docs: reorganize documentation directory structure
[lilypond.git] / Documentation / application / 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.  See TRANSLATION for details.
8 @end ignore
9
10 @c \version "2.12.0"
11
12
13 @node Running LilyPond
14 @chapter Running LilyPond
15
16 This chapter details the technicalities of running LilyPond.
17
18 @menu
19 * Normal usage::
20 * Command-line usage::
21 * Error messages::
22 * Updating files with convert-ly::
23 * Reporting bugs::
24 @end menu
25
26
27 @node Normal usage
28 @section Normal usage
29
30 Most users run LilyPond through a GUI; see @rlearning{First steps} if
31 you have not read this already.
32
33
34 @node Command-line usage
35 @section Command-line usage
36
37 This section contains extra information about using LilyPond on the
38 command-line.  This may be desirable to pass extra options to the
39 program.  In addition, there are certain extra @q{helper} programs (such
40 as @code{midi2ly}) which are only available on the command-line.
41
42 By @q{command-line}, we mean the command line in the operating system.
43 Windows users might be more familiar with the terms @q{DOS shell} or
44 @q{command shell}; MacOS@tie{}X users might be more familiar with the terms
45 @q{terminal} or @q{console}.  They should also consult @ref{Setup
46 for MacOS X}.
47
48 Describing how to use this part of an operating system is outside the
49 scope of this manual; please consult other documentation on this topic
50 if you are unfamiliar with the command-line.
51
52 @menu
53 * Invoking lilypond::
54 * Command line options for lilypond::
55 * Environment variables::
56 @end menu
57
58 @node Invoking lilypond
59 @subsection Invoking @command{lilypond}
60
61 @cindex Invoking @command{lilypond}
62 @cindex command line options for @command{lilypond}
63 @cindex options, command line
64 @cindex switches
65
66
67 The @command{lilypond} executable may be called as follows from the command line.
68
69 @example
70 lilypond [@var{option}]@dots{} @var{file}@dots{}
71 @end example
72
73
74 When invoked with a filename that has no extension, the @file{.ly}
75 extension is tried first.  To read input from stdin, use a
76 dash (@code{-}) for @var{file}.
77
78 When @file{filename.ly} is processed it will produce @file{filename.ps}
79 and @file{filename.pdf} as output.  Several files can be specified;
80 they will each be processed independently.  @footnote{The status of
81 GUILE is not reset after processing a @code{.ly} file, so be careful
82 not to change any system defaults from within Scheme.}
83
84 If @file{filename.ly} contains more than one @code{\score}
85 block, then the rest of the scores will be output in numbered files,
86 starting with @file{filename-1.pdf}.  In addition, the value of
87 @code{output-suffix} will be inserted between the basename and the
88 number.  An input file containing
89
90 @example
91 #(define output-suffix "violin")
92 \score @{ @dots{} @}
93 #(define output-suffix "cello")
94 \score @{ @dots{} @}
95 @end example
96
97 @noindent
98 will output @var{base}@file{-violin.pdf} and
99 @var{base}@file{-cello-1.pdf}.
100
101
102 @node Command line options for lilypond
103 @subsection Command line options for @command{lilypond}
104
105 The following options are supported:
106
107 @table @code
108
109 @item -e,--evaluate=@var{expr}
110 Evaluate the Scheme @var{expr} before parsing any @file{.ly} files.
111 Multiple @code{-e} options may be given, they will be evaluated
112 sequentially.
113
114 The expression will be evaluated in the @code{guile-user} module, so
115 if you want to use definitions in @var{expr}, use
116
117 @example
118 lilypond -e '(define-public a 42)'
119 @end example
120
121 @noindent
122 on the command-line, and include
123
124 @example
125 #(use-modules (guile-user))
126 @end example
127
128 @noindent
129 at the top of the @code{.ly} file.
130
131 @item -f,--format=@var{format}
132 which formats should be written.  Choices for @code{format} are
133 @code{svg}, @code{ps}, @code{pdf}, and @code{png}.
134
135 Example: @code{lilypond -fpng @var{filename}.ly}
136
137
138
139 @item -d,--define-default=@var{var}=@var{val}
140 This sets the internal program option @var{var} to the Scheme value
141 @var{val}.  If @var{val} is not supplied, then @var{#t} is used.  To
142 switch off an option, @code{no-} may be prefixed to @var{var}, e.g.
143
144 @cindex point and click, command line
145
146 @example
147 -dno-point-and-click
148 @end example
149
150 @noindent
151 is the same as
152 @example
153 -dpoint-and-click='#f'
154 @end example
155
156 Here are a few interesting options.
157
158 @table @samp
159 @item help
160 Running @code{lilypond -dhelp} will print all of the @code{-d} options
161 available.
162
163 @item paper-size
164 This option sets the default paper-size,
165 @example
166 -dpaper-size=\"letter\"
167 @end example
168
169 @noindent
170 Note that the string must be enclosed in escaped quotes ( @code{\"} ).
171 @c Match " in previous line to help context-sensitive editors
172
173 @item safe
174 Do not trust the @code{.ly} input.
175
176 When LilyPond formatting is available through a web server, either the
177 @code{--safe} or the @code{--jail} option @b{MUST} be passed.  The
178 @code{--safe} option will prevent inline Scheme code from wreaking
179 havoc, for example
180
181 @quotation
182 @verbatim
183 #(system "rm -rf /")
184 {
185   c4^#(ly:export (ly:gulp-file "/etc/passwd"))
186 }
187 @end verbatim
188 @end quotation
189
190 The @code{-dsafe} option works by evaluating in-line Scheme
191 expressions in a special safe module.  This safe module is derived from
192 GUILE @file{safe-r5rs} module, but adds a number of functions of the
193 LilyPond API.  These functions are listed in @file{scm/@/safe@/-lily@/.scm}.
194
195 In addition, safe mode disallows @code{\include} directives and
196 disables the use of backslashes in @TeX{} strings.
197
198 In safe mode, it is not possible to import LilyPond variables
199 into Scheme.
200
201 @code{-dsafe} does @emph{not} detect resource overuse.  It is still possible to
202 make the program hang indefinitely, for example by feeding cyclic data
203 structures into the backend.  Therefore, if using LilyPond on a
204 publicly accessible webserver, the process should be limited in both
205 CPU and memory usage.
206
207 The safe mode will prevent many useful LilyPond snippets from being
208 compiled.  The @code{--jail} is a more secure alternative, but
209 requires more work to set up.
210
211 @cindex output format, setting
212 @item backend
213 the output format to use for the back-end.  Choices for @code{format} are
214 @table @code
215 @item ps
216 @cindex PostScript output
217  for PostScript.
218
219   Postscript files include TTF, Type1 and OTF fonts.  No subsetting of
220   these fonts is done.  When using oriental character sets, this can
221   lead to huge files.
222
223 @item eps
224  for encapsulated PostScript.  This dumps every page (system) as a separate
225 @file{EPS} file, without fonts, and as one collated @file{EPS} file with
226 all pages (systems) including fonts.
227
228 This mode is used by default by @command{lilypond-book}.
229
230 @item svg
231 @cindex SVG (Scalable Vector Graphics)
232  for SVG (Scalable Vector Graphics).
233
234  This creates a single SVG file containing the entire music
235  output, with embedded fonts.  You need an SVG viewer that
236  supports embedded fonts, or an SVG viewer that can replace the
237  embedded fonts with OTF fonts.  Under UNIX, you may use
238  @uref{http://www.inkscape.org,Inkscape} (version 0.42 or later),
239  after copying the OTF fonts from the LilyPond directory
240  (typically @file{/usr/share/lilypond/VERSION/fonts/otf/}) to
241  @file{~/.fonts/}.
242
243 @item scm
244 @cindex Scheme dump
245  for a dump of the raw, internal Scheme-based drawing commands.
246
247 @item null
248  do not output a printed score; has the same effect as @code{-dno-print-pages}.
249 @end table
250
251 Example: @code{lilypond -dbackend=svg @var{filename}.ly}
252
253 @item preview
254 Generate an output file containing the titles and the first system
255
256 @item print-pages
257 Generate the full pages, the default.  @code{-dno-print-pages} is
258 useful in combination with @code{-dpreview}.
259
260 @end table
261
262
263
264 @item -h,--help
265 Show a summary of usage.
266
267 @item -H,--header=@var{FIELD}
268 Dump a header field to file @file{BASENAME.@var{FIELD}}.
269
270 @item --include, -I=@var{directory}
271 Add @var{directory} to the search path for input files.
272 @cindex file searching
273 @cindex search path
274
275 @item -i,--init=@var{file}
276 Set init file to @var{file} (default: @file{init.ly}).
277
278 @item -o,--output=@var{FILE}
279 Set the default output file to @var{FILE}.  The appropriate
280 suffix will be added (e.g. @code{.pdf} for pdf)
281
282 @item --ps
283 Generate PostScript.
284
285 @item --png
286 Generate pictures of each page, in PNG format.  This implies
287 @code{--ps}.  The resolution in DPI of the image may be set with
288 @example
289 -dresolution=110
290 @end example
291
292 @item --pdf
293 Generate PDF.  This implies @code{--ps}.
294
295
296
297 @item -j,--jail=@var{user},@var{group},@var{jail},@var{dir}
298 Run @command{lilypond} in a chroot jail.
299
300 The @code{--jail} option provides a more flexible alternative to
301 @code{--safe} when LilyPond formatting is available through a web
302 server or whenever LilyPond executes externally provided
303 sources.
304
305 The @code{--jail} option works by changing the root of @command{lilypond} to
306 @var{jail} just before starting the actual compilation process.  The user
307 and group are then changed to match those provided, and the current
308 directory is changed to @var{dir}.  This setup guarantees that it is not
309 possible (at least in theory) to escape from the jail.  Note that for
310 @code{--jail} to work @command{lilypond} must be run as root, which is usually
311 accomplished in a safe way using @command{sudo}.
312
313 Setting up a jail is a slightly delicate matter, as we must be sure that
314 LilyPond is able to find whatever it needs to compile the source
315 @emph{inside the jail}.  A typical setup comprises the following items:
316
317 @table @asis
318 @item Setting up a separate filesystem
319 A separate filesystem should be created for LilyPond, so that it can be
320 mounted with safe options such as @code{noexec}, @code{nodev}, and
321 @code{nosuid}.  In this way, it is impossible to run executables or to
322 write directly to a device from LilyPond.  If you do not want to create a
323 separate partition, just create a file of reasonable size and use it to
324 mount a loop device.  A separate filesystem also guarantees that LilyPond
325 cannot write more space than it is allowed.
326
327 @item Setting up a separate user
328 A separate user and group (say, @code{lily}/@code{lily}) with low
329 privileges should be used to run LilyPond inside the jail.  There should
330 be a single directory writable by this user, which should be passed in
331 @var{dir}.
332
333 @item Preparing the jail
334 LilyPond needs to read a number of files while running.  All these files
335 are to be copied into the jail, under the same path they appear in the
336 real root filesystem.  The entire content of the LilyPond installation
337 (e.g., @file{/usr/share/lilypond})
338 should be copied.
339
340 If problems arise, the simplest way to trace them down is to run
341 LilyPond using @command{strace}, which will allow you to determine which
342 files are missing.
343
344 @item Running LilyPond
345 In a jail mounted with @code{noexec} it is impossible to execute any external
346 program.  Therefore LilyPond must be run with a backend that does not
347 require any such program.  As we already mentioned, it must be also run
348 with superuser privileges (which, of course, it will lose immediately),
349 possibly using @command{sudo}.  It is a good idea to limit the number of
350 seconds of CPU time LilyPond can use (e.g., using @command{ulimit
351 -t}), and, if your operating system supports it, the amount of memory
352 that can be allocated.
353 @end table
354
355
356 @item -v,--version
357 Show version information.
358
359 @item -V,--verbose
360 Be verbose: show full paths of all files read, and give timing
361 information.
362
363 @item -w,--warranty
364 Show the warranty with which GNU LilyPond comes. (It comes with
365 @strong{NO WARRANTY}!)
366 @end table
367
368 @node Environment variables
369 @subsection Environment variables
370
371
372 @cindex LANG
373 @cindex LILYPOND_DATADIR
374
375 @command{lilypond} recognizes the following environment variables:
376 @table @code
377 @item LILYPOND_DATADIR
378 This specifies a directory where locale messages and
379 data files will be looked up by default.  The directory should contain
380 subdirectories called @file{ly/}, @file{ps/}, @file{tex/}, etc.
381
382 @item LANG
383 This selects the language for the warning messages.
384
385 @item LILYPOND_GC_YIELD
386 With this variable the memory footprint and performance can be
387 adjusted.  It is a percentage tunes memory management behavior.  With
388 higher values, the program uses more memory, with smaller values, it
389 uses more CPU time.  The default value is @code{70}.
390
391 @end table
392
393
394 @node Error messages
395 @section Error messages
396
397 @cindex error messages
398 Different error messages can appear while compiling a file:
399
400 @table @emph
401
402 @item Warning
403 @cindex warning
404 Something looks suspect.  If you are requesting something out of the
405 ordinary then you will understand the message, and can ignore it.
406 However, warnings usually indicate that something is wrong with the
407 input file.
408
409 @item Error
410 Something is definitely wrong.  The current processing step (parsing,
411 interpreting, or formatting) will be finished, but the next step will
412 be skipped.
413
414 @item Fatal error
415 @cindex error
416 @cindex fatal error
417 Something is definitely wrong, and LilyPond cannot continue.  This
418 happens rarely.  The most usual cause is misinstalled fonts.
419
420 @item Scheme error
421 @cindex trace, Scheme
422 @cindex call trace
423 @cindex Scheme error
424 Errors that occur while executing Scheme code are caught by the Scheme
425 interpreter.  If running with the verbose option (@code{-V} or
426 @code{--verbose}) then a call trace of the offending
427 function call is printed.
428
429 @item Programming error
430 @cindex Programming error
431 There was some internal inconsistency.  These error messages are
432 intended to help the programmers and debuggers.  Usually, they can be
433 ignored.  Sometimes, they come in such big quantities that they obscure
434 other output.
435
436 @item Aborted (core dumped)
437 This signals a serious programming error that caused the program to
438 crash.  Such errors are considered critical.  If you stumble on one,
439 send a bug-report.
440 @end table
441
442 @cindex errors, message format
443 If warnings and errors can
444 be linked to some part of the input file, then error messages have the
445 following form
446
447 @example
448 @var{filename}:@var{lineno}:@var{columnno}: @var{message}
449 @var{offending input line}
450 @end example
451
452 A line-break is inserted in the offending line to indicate the column
453 where the error was found.  For example,
454
455 @example
456 test.ly:2:19: error: not a duration: 5
457   @{ c'4 e'
458            5 g' @}
459 @end example
460
461 These locations are LilyPond's best guess about where the warning or
462 error occurred, but (by their very nature) warnings and errors occur
463 when something unexpected happens.  If you can't see an error in the
464 indicated line of your input file, try checking one or two lines
465 above the indicated position.
466
467
468 @node Updating files with convert-ly
469 @section Updating files with @command{convert-ly}
470
471 @cindex Updating a LilyPond file
472 @cindex convert-ly
473
474 The LilyPond input syntax is routinely changed to simplify it or improve
475 it in different ways.  As a side effect of this, the LilyPond interpreter
476 often is no longer compatible with older input files.  To remedy this,
477 the program @command{convert-ly} can be used to deal with most of the
478 syntax changes between LilyPond versions.
479
480 @menu
481 * Invoking convert-ly::
482 * Command line options for convert-ly::
483 * Problems with convert-ly::
484 @end menu
485
486 @node Invoking convert-ly
487 @subsection Invoking @command{convert-ly}
488
489 @command{convert-ly} uses @code{\version} statements in the input
490 file to detect the old version number.  In most cases, to upgrade
491 your input file it is sufficient to run
492
493 @example
494 convert-ly -e myfile.ly
495 @end example
496
497 @noindent
498 in the directory containing the file.  This will upgrade
499 @code{myfile.ly} in-place and preserve the original file in
500 @code{myfile.ly~}.
501
502 To convert all the input files in a directory together use
503
504 @example
505 convert-ly -e *.ly
506 @end example
507
508 Alternatively, if you want to specify a different name for the
509 upgraded file, preserving the original file and name unchanged,
510 use
511
512 @example
513 convert-ly myfile.ly > mynewfile.ly
514 @end example
515
516 @command{convert-ly} always converts up to the last syntax change
517 handled by it.  This means that the @code{\version} number left in
518 the file is usually lower than the version of @command{convert-ly}
519 itself.
520
521 The program will list the version numbers for which conversions
522 have been made.  If no version numbers are listed the file is
523 already up to date.
524
525 @noindent
526 MacOS@tie{}X users may execute these commands under the menu entry
527 @code{Compile > Update syntax}.
528
529 Windows users should enter these commands in a Command Prompt window,
530 which is usually found under
531 @code{Start > Accessories > Command Prompt}.
532
533 @node Command line options for convert-ly
534 @subsection Command line options for @command{convert-ly}
535
536 In general, the program is invoked as follows:
537
538 @example
539 convert-ly [@var{option}]@dots{} @var{filename}@dots{}
540 @end example
541
542
543 The following options can be given:
544
545 @table @code
546 @item -e,--edit
547 Apply the conversions direct to the input file, modifying it
548 in-place.
549
550 @item -f,--from=@var{from-patchlevel}
551 Set the version to convert from.  If this is not set, @command{convert-ly}
552 will guess this, on the basis of @code{\version} strings in the file.
553 E.g. @code{--from=2.10.25}
554
555 @item -n,--no-version
556 Normally, @command{convert-ly} adds a @code{\version} indicator
557 to the output.  Specifying this option suppresses this.
558
559 @item -s, --show-rules
560 Show all known conversions and exit.
561
562 @item --to=@var{to-patchlevel}
563 Set the goal version of the conversion.  It defaults to the latest
564 available version.  E.g. @code{--to=2.12.2}
565
566 @item -h, --help
567 Print usage help.
568 @end table
569
570 To upgrade LilyPond fragments in texinfo files, use
571
572 @example
573 convert-ly --from=... --to=... --no-version *.itely
574 @end example
575
576 To see the changes in the LilyPond syntax between two versions, use
577
578 @example
579 convert-ly --from=... --to=... -s
580 @end example
581
582
583 @node Problems with convert-ly
584 @subsection Problems with @code{convert-ly}
585
586 When running convert-ly in a Command Prompt window under Windows
587 on a file which has spaces in the filename or in the path to it,
588 it is necessary to surround the entire input file name with three
589 (!) sets of double quotes:
590
591 @example
592 convert-ly """D:/My Scores/Ode.ly""" > "D:/My Scores/new Ode.ly"
593 @end example
594
595 If the simple @command{convert-ly -e *.ly} command fails because the
596 expanded command line becomes too long, the @command{convert-ly}
597 command may be placed in a loop instead.  This example for UNIX
598 will upgrade all @code{.ly} files in the current directory
599
600 @example
601 for f in *.ly; do convert-ly -e $f; done;
602 @end example
603
604 In the Windows Command Prompt window the corresponding command is
605
606 @example
607 for %x in (*.ly) do convert-ly -e """%x"""
608 @end example
609
610 Not all language changes are handled.  Only one output option can be
611 specified.  Automatically updating scheme and LilyPond scheme
612 interfaces is quite unlikely; be prepared to tweak scheme code
613 manually.
614
615 @verbatim
616 There are a few things that the convert-ly cannot handle.  Here's a list
617 of limitations that the community has complained about.
618
619 This bug report structure has been chosen because convert-ly has a
620 structure that doesn't allow to smoothly implement all needed changes.
621 Thus this is just a wishlist, placed here for reference.
622
623 1.6->2.0:
624  Doesn't always convert figured bass correctly, specifically things like {<
625 >}.  Mats' comment on working around this:
626    To be able to run convert-ly
627    on it, I first replaced all occurrences of '{<' to some dummy like '{#'
628    and similarly I replaced '>}' with '&}'.  After the conversion, I could
629    then change back from '{ #' to '{ <' and from '& }' to '> }'.
630  Doesn't convert all text markup correctly.  In the old markup syntax,
631  it was possible to group a number of markup commands together within
632 parentheses, e.g.
633    -#'((bold italic) "string")
634    This will incorrectly be converted into
635    -\markup{{\bold italic} "string"}
636    instead of the correct
637    -\markup{\bold \italic "string"}
638 2.0->2.2:
639  Doesn't handle \partcombine
640  Doesn't do \addlyrics => \lyricsto, this breaks some scores with multiple
641 stanzas.
642 2.0->2.4:
643  \magnify isn't changed to \fontsize.
644     - \magnify #m => \fontsize #f, where f = 6ln(m)/ln(2)
645  remove-tag isn't changed.
646     - \applyMusic #(remove-tag '. . .) => \keepWithTag #'. . .
647  first-page-number isn't changed.
648     - first-page-number no => print-first-page-number = ##f
649  Line breaks in header strings aren't converted.
650     - \\\\  as line break in \header strings => \markup \center-align <
651       "First Line" "Second Line" >
652  Crescendo and decrescendo terminators aren't converted.
653     - \rced => \!
654     - \rc => \!
655 2.2->2.4:
656  \turnOff (used in \set Staff.VoltaBracket = \turnOff) is not properly
657 converted.
658 2.4.2->2.5.9
659  \markup{ \center-align <{ ... }> } should be converted to:
660  \markup{ \center-align {\line { ... }} }
661  but now, \line is missing.
662 2.4->2.6
663  Special LaTeX characters such as $~$ in text are not converted to UTF8.
664 2.8
665  \score{} must now begin with a music expression.  Anything else
666  (particularly \header{}) must come after the music.
667 @end verbatim
668
669
670 @node Reporting bugs
671 @section Reporting bugs
672
673 @cindex bugs
674 @cindex reporting bugs
675
676 If you have input that results in a crash or an erroneous output, then
677 that is a bug.  There is a list of current bugs on our Google bug tracker,
678
679 @uref{http://code.google.com/p/lilypond/issues/list}
680
681 If you have discovered a bug which is not listed, please report the
682 bug by following the directions on
683
684 @uref{http://lilypond.org/web/devel/participating/bugs}
685
686 Please construct and submit minimal examples of bugs in reports.  We do not
687 have the resources to investigate reports which are not as small as possible.
688
689
690