]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/running.itely
Merge master into nested-bookparts
[lilypond.git] / Documentation / user / running.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @c This file is part of lilypond-program.tely
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.11.61"
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 \book @{ @dots{} @}
93 #(define output-suffix "cello")
94 \book @{ @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}, @code{png}, @code{tex}, @code{dvi}.
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 @item backend
212 the output format to use for the back-end.  Choices for @code{format} are
213 @table @code
214 @item tex
215 for @TeX{} output, to be processed with La@TeX{}.  If present, the file
216 @file{file.textmetrics} is read to determine text extents.
217 @item texstr
218 dump text strings to @file{.texstr} file, which can be run through
219 (La)@TeX{}, resulting in a @code{.textmetrics} file, which contains the
220 extents of strings of text.  @strong{Warning:} this functionality is
221 currently missing due to heavy restructuring of the source code.
222 @item ps
223  for PostScript.
224 @cindex PostScript output
225
226   Postscript files include TTF, Type1 and OTF fonts.  No subsetting of
227   these fonts is done.  When using oriental character sets, this can
228   lead to huge files.
229
230 @item eps
231  for encapsulated PostScript.  This dumps every page (system) as a separate
232 @file{EPS} file, without fonts, and as one collated @file{EPS} file with
233 all pages (systems) including fonts.
234
235 This mode is used by default by @command{lilypond-book}.
236
237 @item svg
238  for SVG (Scalable Vector Graphics).  This dumps every page as a separate
239 @file{SVG} file, with embedded fonts.
240 @cindex SVG (Scalable Vector Graphics)
241   You need a SVG viewer which supports embedded fonts, or a SVG
242   viewer which is able to replace the embedded fonts with OTF fonts.
243   Under UNIX, you may use @uref{http://www.inkscape.org,Inkscape}
244   (version 0.42 or later), after copying the OTF fonts from the LilyPond directory
245   (typically @file{/usr/share/lilypond/VERSION/fonts/otf/}) to @file{~/.fonts/}.
246 @item scm
247  for a dump of the raw, internal Scheme-based drawing commands.
248 @cindex Scheme dump
249 @end table
250
251 Example: @code{lilypond -dbackend=svg @var{filename}.ly}
252
253 @cindex output format, setting
254
255 @item preview
256 Generate an output file containing the titles and the first system
257
258 @item print-pages
259 Generate the full pages, the default.  @code{-dno-print-pages} is
260 useful in combination with @code{-dpreview}.
261
262 @end table
263
264
265
266 @item -h,--help
267 Show a summary of usage.
268
269 @item -H,--header=@var{FIELD}
270 Dump a header field to file @file{BASENAME.@var{FIELD}}.
271
272 @item --include, -I=@var{directory}
273 Add @var{directory} to the search path for input files.
274 @cindex file searching
275 @cindex search path
276
277 @item -i,--init=@var{file}
278 Set init file to @var{file} (default: @file{init.ly}).
279
280 @item -o,--output=@var{FILE}
281 Set the default output file to @var{FILE}.  The appropriate
282 suffix will be added (i.e. @code{.pdf} for pdf, @code{.tex}
283 for tex, etc).
284
285 @item --ps
286 Generate PostScript.
287
288 @item --dvi
289 Generate DVI files.  In this case, the @TeX{} backend should be
290 specified, i.e., @code{-dbackend=tex}.
291
292 @item --png
293 Generate pictures of each page, in PNG format.  This implies
294 @code{--ps}.  The resolution in DPI of the image may be set with
295 @example
296 -dresolution=110
297 @end example
298
299 @item --pdf
300 Generate PDF.  This implies @code{--ps}.
301
302
303
304 @item -j,--jail=@var{user},@var{group},@var{jail},@var{dir}
305 Run @command{lilypond} in a chroot jail.
306
307 The @code{--jail} option provides a more flexible alternative to
308 @code{--safe} when LilyPond formatting is available through a web
309 server or whenever LilyPond executes externally provided
310 sources.
311
312 The @code{--jail} option works by changing the root of @command{lilypond} to
313 @var{jail} just before starting the actual compilation process.  The user
314 and group are then changed to match those provided, and the current
315 directory is changed to @var{dir}.  This setup guarantees that it is not
316 possible (at least in theory) to escape from the jail.  Note that for
317 @code{--jail} to work @command{lilypond} must be run as root, which is usually
318 accomplished in a safe way using @command{sudo}.
319
320 Setting up a jail is a slightly delicate matter, as we must be sure that
321 LilyPond is able to find whatever it needs to compile the source
322 @emph{inside the jail}.  A typical setup comprises the following items:
323
324 @table @asis
325 @item Setting up a separate filesystem
326 A separate filesystem should be created for LilyPond, so that it can be
327 mounted with safe options such as @code{noexec}, @code{nodev}, and
328 @code{nosuid}.  In this way, it is impossible to run executables or to
329 write directly to a device from LilyPond.  If you do not want to create a
330 separate partition, just create a file of reasonable size and use it to
331 mount a loop device.  A separate filesystem also guarantees that LilyPond
332 cannot write more space than it is allowed.
333
334 @item Setting up a separate user
335 A separate user and group (say, @code{lily}/@code{lily}) with low
336 privileges should be used to run LilyPond inside the jail.  There should
337 be a single directory writable by this user, which should be passed in
338 @var{dir}.
339
340 @item Preparing the jail
341 LilyPond needs to read a number of files while running.  All these files
342 are to be copied into the jail, under the same path they appear in the
343 real root filesystem.  The entire content of the LilyPond installation
344 (e.g., @file{/usr/share/lilypond})
345 should be copied.
346
347 If problems arise, the simplest way to trace them down is to run
348 LilyPond using @command{strace}, which will allow you to determine which
349 files are missing.
350
351 @item Running LilyPond
352 In a jail mounted with @code{noexec} it is impossible to execute any external
353 program.  Therefore LilyPond must be run with a backend that does not
354 require any such program.  As we already mentioned, it must be also run
355 with superuser privileges (which, of course, it will lose immediately),
356 possibly using @command{sudo}.  It is a good idea to limit the number of
357 seconds of CPU time LilyPond can use (e.g., using @command{ulimit
358 -t}), and, if your operating system supports it, the amount of memory
359 that can be allocated.
360 @end table
361
362
363 @item -v,--version
364 Show version information.
365
366 @item -V,--verbose
367 Be verbose: show full paths of all files read, and give timing
368 information.
369
370 @item -w,--warranty
371 Show the warranty with which GNU LilyPond comes. (It comes with
372 @strong{NO WARRANTY}!)
373 @end table
374
375 @node Environment variables
376 @subsection Environment variables
377
378
379 @cindex LANG
380 @cindex LILYPOND_DATADIR
381
382 @command{lilypond} recognizes the following environment variables:
383 @table @code
384 @item LILYPOND_DATADIR
385 This specifies a directory where locale messages and
386 data files will be looked up by default.  The directory should contain
387 subdirectories called @file{ly/}, @file{ps/}, @file{tex/}, etc.
388
389 @item LANG
390 This selects the language for the warning messages.
391
392 @item LILYPOND_GC_YIELD
393 With this variable the memory footprint and performance can be
394 adjusted.  It is a percentage tunes memory management behavior.  With
395 higher values, the program uses more memory, with smaller values, it
396 uses more CPU time.  The default value is @code{70}.
397
398 @end table
399
400
401 @node Error messages
402 @section Error messages
403
404 @cindex error messages
405 Different error messages can appear while compiling a file:
406
407 @table @emph
408
409 @item Warning
410 @cindex warning
411 Something looks suspect.  If you are requesting something out of the
412 ordinary then you will understand the message, and can ignore it.
413 However, warnings usually indicate that something is wrong with the
414 input file.
415
416 @item Error
417 Something is definitely wrong.  The current processing step (parsing,
418 interpreting, or formatting) will be finished, but the next step will
419 be skipped.
420
421 @item Fatal error
422 @cindex error
423 @cindex fatal error
424 Something is definitely wrong, and LilyPond cannot continue.  This
425 happens rarely.  The most usual cause is misinstalled fonts.
426
427 @item Scheme error
428 @cindex trace, Scheme
429 @cindex call trace
430 @cindex Scheme error
431 Errors that occur while executing Scheme code are caught by the Scheme
432 interpreter.  If running with the verbose option (@code{-V} or
433 @code{--verbose}) then a call trace of the offending
434 function call is printed.
435
436 @item Programming error
437 @cindex Programming error
438 There was some internal inconsistency.  These error messages are
439 intended to help the programmers and debuggers.  Usually, they can be
440 ignored.  Sometimes, they come in such big quantities that they obscure
441 other output.
442
443 @item Aborted (core dumped)
444 This signals a serious programming error that caused the program to
445 crash.  Such errors are considered critical.  If you stumble on one,
446 send a bug-report.
447 @end table
448
449 @cindex errors, message format
450 If warnings and errors can
451 be linked to some part of the input file, then error messages have the
452 following form
453
454 @example
455 @var{filename}:@var{lineno}:@var{columnno}: @var{message}
456 @var{offending input line}
457 @end example
458
459 A line-break is inserted in the offending line to indicate the column
460 where the error was found.  For example,
461
462 @example
463 test.ly:2:19: error: not a duration: 5
464   @{ c'4 e'
465            5 g' @}
466 @end example
467
468 These locations are LilyPond's best guess about where the warning or
469 error occurred, but (by their very nature) warnings and errors occur
470 when something unexpected happens.  If you can't see an error in the
471 indicated line of your input file, try checking one or two lines
472 above the indicated position.
473
474
475 @node Updating files with convert-ly
476 @section Updating files with @command{convert-ly}
477
478 @cindex Updating a LilyPond file
479 @cindex convert-ly
480
481 The LilyPond input syntax is routinely changed to simplify it or improve
482 it in different ways.  As a side effect of this, the LilyPond interpreter
483 often is no longer compatible with older input files.  To remedy this,
484 the program @command{convert-ly} can be used to deal with most of the
485 syntax changes between LilyPond versions.
486
487 It uses @code{\version} statements in the input files to detect the
488 old version number.  In most cases, to upgrade your input file it is
489 sufficient to run
490
491 @example
492 convert-ly -e myfile.ly
493 @end example
494
495 @noindent
496 MacOS@tie{}X users may execute this command under the menu entry
497 @code{Compile > Update syntax}.
498
499 If there are no changes to myfile.ly and file called myfile.ly.NEW
500 is created, then myfile.ly is already updated.
501
502 @menu
503 * Command line options for convert-ly::
504 * Problems with convert-ly::
505 @end menu
506
507 @node Command line options for convert-ly
508 @subsection Command line options for @command{convert-ly}
509
510 @command{convert-ly} always converts up to the last syntax change handled by
511 it.  This means that the @code{\version} number left in the file is
512 usually lower than the version of @command{convert-ly} itself.
513
514 To upgrade LilyPond fragments in texinfo files, use
515
516 @example
517 convert-ly --from=... --to=... --no-version *.itely
518 @end example
519
520 To see the changes in the LilyPond syntax between two versions, use
521
522 @example
523 convert-ly --from=... --to=... -s
524 @end example
525
526 To upgrade many files at once, combine @code{convert-ly} with
527 standard UNIX commands.  This example will upgrade all @code{.ly}
528 files in the current directory
529
530 @example
531 for f in *.ly; do convert-ly -e $f; done;
532 @end example
533
534 In general, the program is invoked as follows:
535
536 @example
537 convert-ly [@var{option}]@dots{} @var{file}@dots{}
538 @end example
539
540
541 The following options can be given:
542
543 @table @code
544 @item -e,--edit
545 Do an inline edit of the input file.  Overrides @code{--output}.
546
547 @item -f,--from=@var{from-patchlevel}
548 Set the version to convert from.  If this is not set, @command{convert-ly}
549 will guess this, on the basis of @code{\version} strings in the file.
550
551 @item -n,--no-version
552 Normally, @command{convert-ly} adds a @code{\version} indicator
553 to the output.  Specifying this option suppresses this.
554
555 @item -s, --show-rules
556 Show all known conversions and exit.
557
558 @item --to=@var{to-patchlevel}
559 Set the goal version of the conversion.  It defaults to the latest
560 available version.
561
562 @item -h, --help
563 Print usage help.
564 @end table
565
566
567 @node Problems with convert-ly
568 @subsection Problems with @code{convert-ly}
569
570 Not all language changes are handled.  Only one output option can be
571 specified.  Automatically updating scheme and LilyPond scheme
572 interfaces is quite unlikely; be prepared to tweak scheme code
573 manually.
574
575 @verbatim
576 There are a few things that the convert-ly cannot handle.  Here's a list
577 of limitations that the community has complained about.
578
579 This bug report structure has been chosen because convert-ly has a
580 structure that doesn't allow to smoothly implement all needed changes.
581 Thus this is just a wishlist, placed here for reference.
582
583 1.6->2.0:
584  Doesn't always convert figured bass correctly, specifically things like {<
585 >}.  Mats' comment on working around this:
586    To be able to run convert-ly
587    on it, I first replaced all occurrences of '{<' to some dummy like '{#'
588    and similarly I replaced '>}' with '&}'.  After the conversion, I could
589    then change back from '{ #' to '{ <' and from '& }' to '> }'.
590  Doesn't convert all text markup correctly.  In the old markup syntax,
591  it was possible to group a number of markup commands together within
592 parentheses, e.g.
593    -#'((bold italic) "string")
594    This will incorrectly be converted into
595    -\markup{{\bold italic} "string"}
596    instead of the correct
597    -\markup{\bold \italic "string"}
598 2.0->2.2:
599  Doesn't handle \partcombine
600  Doesn't do \addlyrics => \lyricsto, this breaks some scores with multiple
601 stanzas.
602 2.0->2.4:
603  \magnify isn't changed to \fontsize.
604     - \magnify #m => \fontsize #f, where f = 6ln(m)/ln(2)
605  remove-tag isn't changed.
606     - \applyMusic #(remove-tag '. . .) => \keepWithTag #'. . .
607  first-page-number isn't changed.
608     - first-page-number no => print-first-page-number = ##f
609  Line breaks in header strings aren't converted.
610     - \\\\  as line break in \header strings => \markup \center-align <
611       "First Line" "Second Line" >
612  Crescendo and decrescendo terminators aren't converted.
613     - \rced => \!
614     - \rc => \!
615 2.2->2.4:
616  \turnOff (used in \set Staff.VoltaBracket = \turnOff) is not properly
617 converted.
618 2.4.2->2.5.9
619  \markup{ \center-align <{ ... }> } should be converted to:
620  \markup{ \center-align {\line { ... }} }
621  but now, \line is missing.
622 2.4->2.6
623  Special LaTeX characters such as $~$ in text are not converted to UTF8.
624 2.8
625  \score{} must now begin with a music expression.  Anything else
626  (particularly \header{}) must come after the music.
627 @end verbatim
628
629
630 @node Reporting bugs
631 @section Reporting bugs
632
633 @cindex bugs
634 @cindex reporting bugs
635
636 If you have input that results in a crash or an erroneous output, then
637 that is a bug.  There is a list of current bugs on our Google bug tracker,
638
639 @uref{http://code.google.com/p/lilypond/issues/list}
640
641 If you have discovered a bug which is not listed, please report the
642 bug by following the directions on
643
644 @uref{http://lilypond.org/web/devel/participating/bugs}
645
646 Please construct and submit minimal examples of bugs in reports.  We do not
647 have the resources to investigate reports which are not as small as possible.
648
649
650