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