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