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