]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/invoking.itely
* lily/parser.yy (assignment_id): allow LYRICS_STRING as
[lilypond.git] / Documentation / user / invoking.itely
1 @c -*- coding: latin-1; 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 * Error messages::
11 * Reporting bugs::
12 * Editor support::
13 * Invoking lilypond-latex::
14 @end menu
15
16 @node Invoking lilypond
17 @section Invoking lilypond
18 @cindex Invoking LilyPond
19 @cindex command line options
20 @cindex options, command line
21 @cindex switches
22
23
24 The @code{lilypond} executable may be called as follows from the command line.
25
26 @example
27 lilypond [@var{option}]@dots{} @var{file}@dots{}
28 @end example
29
30
31 When invoked with a filename that has no extension, the @file{.ly}
32 extension is tried first.  To read input from stdin, use a
33 dash (@code{-}) for @var{file}.
34
35 When @file{filename.ly} is processed it will produce
36 @file{filename.tex} as output (or @file{filename.ps} for PostScript
37 output).  If @file{filename.ly} contains more than one @code{\score}
38 block, then the rest of the scores will be output in numbered files,
39 starting with @file{filename-1.tex}.  Several files can be specified;
40 they will each be processed independently.  @footnote{The status of
41 GUILE is not reset after processing a @code{.ly} file, so be careful
42 not to change any system defaults from within Scheme.}
43
44
45 @section Command line options
46
47 The following options are supported:
48
49 @table @code
50
51 @item -e,--evaluate=@var{expr}
52 Evaluate the Scheme @var{expr} before parsing any @file{.ly} files.
53 Multiple @code{-e} options may be given, they will be evaluated
54 sequentially.  The function @code{ly:set-option} allows access to
55 some internal variables.  Use @code{-e '(ly:option-usage)'} for more
56 information.
57
58 @item -f,--format=@var{format}
59 which formats should be written. Choices are @code{svg}, @code{ps},
60 @code{pdf}, @code{png}, @code{tex}, @code{dvi}.
61
62 @item -b,--backend=@var{format}
63 the output format to use for the back-end.  Choices are
64 @table @code
65 @item tex
66 for @TeX{} output, to be processed with La@TeX{}.  If present, the file
67 @file{file.textmetrics} is read to determine text extents.
68 @item texstr
69 dump text strings to @file{.texstr} file, which can be run through
70 (La)@TeX{}, resulting in a @code{.textmetrics} file, which contains the
71 extents of strings of text.
72 @item ps
73  for PostScript
74 @cindex PostScript output
75 @item eps
76  for encapsulated PostScript. This dumps every page (system) as a separate
77 @file{EPS} file, without fonts, and as one collated @file{EPS} file with
78 all pages (systems) including fonts.
79
80 This mode  is used by default by lilypond-book.
81
82 @item svg
83  for SVG (Scalable Vector Graphics)
84 @cindex SVG (Scalable Vector Graphics)
85 @item scm
86  for a dump of the raw, internal Scheme-based drawing commands.
87 @cindex Scheme dump
88 @end table
89  
90 @cindex output format, setting
91
92 @item -h,--help
93 Show a summary of usage.
94
95 @item --include, -I=@var{directory}
96 Add @var{directory} to the search path for input files.
97 @cindex file searching
98 @cindex search path
99
100 @item -i,--init=@var{file}
101 Set init file to @var{file} (default: @file{init.ly}).
102
103 @item -o,--output=@var{FILE}
104 Set the default output file to @var{FILE}.  The appropriate
105 suffix will be added (ie @code{.pdf} for pdf, @code{.tex}
106 for tex, etc).
107
108 @item --ps
109 Generate PostScript.
110
111 @item --dvi
112 Generate DVI files.  In this case, the @TeX{} backend should be
113 specified, i.e., @code{-f tex}.
114
115 @item --png
116 Generate pictures of each page, in PNG format.  This implies @code{--ps}.
117
118 @item --pdf
119 Generate PDF.  This implies @code{--ps}.
120
121 @item --preview
122 Generate an output file containing the titles and the first system
123
124 @item --no-pages
125 Do not generate the full pages.  Useful in combination with
126 @code{--preview}.
127
128 @item -s,--safe
129 Do not trust the @code{.ly} input.
130
131 When LilyPond formatting is available through a web server, the
132 @code{--safe} @b{MUST} be passed.  This will prevent inline Scheme
133 code from wreaking havoc, for example
134
135 @quotation
136 @verbatim
137 #(system "rm -rf /")
138 {
139   c4^#(ly:export (ly:gulp-file "/etc/passwd"))
140 }
141 @end verbatim
142 @end quotation
143
144 The @code{--safe} option works by evaluating in-line Scheme
145 expressions in a special safe module.  This safe module is derived from
146 GUILE @file{safe-r5rs} module, but adds a number of functions of the
147 LilyPond API.  These functions are listed in @file{scm/@/safe@/-lily@/.scm}.
148
149 In addition, @code{--safe} disallows @code{\include} directives and
150 disables the use of backslashes in @TeX{} strings.
151
152 In @code{--safe} mode, it is not possible to import LilyPond variables
153 into Scheme.
154
155 @code{--safe} does @emph{not} detect resource overuse. It is still
156 possible to make the program hang indefinitely, for example by feeding
157 cyclic data structures into the backend.  Therefore, if using LilyPond
158 on a publicly accessible webserver, the process should be limited in
159 both CPU and memory usage.
160
161 @item -v,--version
162 Show version information.
163
164 @item -V,--verbose
165 Be verbose: show full paths of all files read, and give timing
166 information.
167
168 @item -w,--warranty
169 Show the warranty with which GNU LilyPond comes. (It comes with
170 @strong{NO WARRANTY}!)
171 @end table
172
173
174 @section Environment variables
175
176 For processing both the @TeX{} and the PostScript output, the
177 appropriate environment variables must be set.  The following scripts
178 do this:
179
180 @itemize @bullet
181 @item @file{buildscripts/@/out/@/lilypond@/-profile}
182 (for SH shells)
183 @item @file{buildscripts/@/out/@/lilypond@/-login} (for C-shells)
184 @end itemize
185
186 They should normally be sourced as part of the login process.  If these
187 scripts are not run from the system wide login process, then you must
188 run them yourself.
189
190 @cindex installing LilyPond
191
192 If you use sh, bash, or a similar shell, then add the following to
193 your @file{.profile}:
194 @example
195 . @var{/the/path/to/}lilypond-profile
196 @end example
197
198 If you use csh, tcsh or a similar shell, then add the following to
199 your @file{~/.login}:
200 @example
201 source @var{/the/path/to/}lilypond-login
202 @end example
203
204 Of course, in both cases, you should substitute the proper location of
205 either script.
206
207 These scripts set the following variables:
208 @table @code
209 @item TEXMF
210 To make sure that @TeX{} and lilypond find data files (among
211 others @file{.tex}, @file{.mf}, and @file{.tfm}),
212 you have to set @code{TEXMF} to point to the lilypond data
213 file tree.  A typical setting would be
214 @example
215 @{/usr/share/lilypond/2.4.0,@{!!/usr/share/texmf@}@}
216 @end example
217
218 @end table
219
220
221 @cindex PostScript
222 @cindex TEXMF
223 @cindex printing postscript
224
225 The binary itself recognizes the following environment variables:
226 @table @code
227 @item LILYPONDPREFIX
228 This specifies a directory where locale messages and
229 data files will be looked up by default.  The directory should contain
230 subdirectories called @file{ly/}, @file{ps/}, @file{tex/}, etc.
231
232 @item LANG
233 This selects the language for the warning messages.
234 @end table
235
236 @cindex LANG
237 @cindex LILYPONDPREFIX
238
239 @node Error messages
240 @section Error messages
241
242 @cindex error messages
243 Different error messages can appear while compiling a file:
244
245 @table @emph
246 @cindex warning
247
248 @item Warning
249 Something looks suspect.  If you are requesting something out of the
250 ordinary then you will understand the message, and can ignore it.
251 However, warnings usually indicate that something is wrong with the
252 input file.
253
254 @item Error
255 Something is definitely wrong.  The current processing step (parsing,
256 interpreting, or formatting) will be finished, but the next step will
257 be skipped.
258
259 @cindex error
260 @cindex fatal error
261 @item Fatal error
262 Something is definitely wrong, and LilyPond cannot continue.  This
263 happens rarely.  The most usual cause is misinstalled fonts.
264
265 @cindex trace, Scheme
266 @cindex call trace
267 @cindex Scheme error
268 @item Scheme error
269 Errors that occur while executing Scheme code are caught by the Scheme
270 interpreter.  If running with the verbose option (@code{-V} or
271 @code{--verbose}) then a call trace of the offending
272 function call is printed.
273
274 @cindex Programming error
275 @item Programming error
276 There was some internal inconsistency.  These error messages are
277 intended to help the programmers and debuggers.  Usually, they can be
278 ignored.  Sometimes, they come in such big quantities that they obscure
279 other output.  In this case, file a bug-report.
280
281 @item Aborted (core dumped)
282 This signals a serious programming error that caused the program to
283 crash.  Such errors are considered critical.  If you stumble on one,
284 send a bug-report.
285
286
287 @end table
288
289 @cindex errors, message format
290 If warnings and errors can
291 be linked to some part of the input file, then error messages have the
292 following form
293
294 @example
295 @var{filename}:@var{lineno}:@var{columnno}: @var{message}
296 @var{offending input line}
297 @end example
298
299 A line-break is inserted in the offending line to indicate the column
300 where the error was found.  For example,
301
302 @example
303 test.ly:2:19: error: not a duration: 5:
304   @{ c'4 e'5
305              g' @}
306 @end example
307
308 These locations are LilyPond's best guess about where the warning or
309 error occured, but (by their very nature) warnings and errors occur
310 when something unexpected happens.  If you can't see an error in the
311 indicated line of your input file, try checking one or two lines
312 above the indicated position.
313
314
315 @node Reporting bugs
316 @section Reporting bugs
317
318 @cindex bugs
319 @cindex reporting bugs
320
321 If you have input that results in a crash or an erroneous output, then
322 that is a bug.  We try to respond to bug-reports promptly, and fix them as
323 soon as possible.  Help us by sending a defective input file, so we can
324 reproduce the problem.  Make it small, so we can easily debug the
325 problem.  Don't forget to tell which version of LilyPond you use!  Send
326 the report to @email{bug-lilypond@@gnu.org}.
327
328 When you've found a bug, have a look at our
329 @uref{http://@/lilypond@/.org/@/doc/@/v2.3/@/bugs/,bug database} to see if
330 it has already been reported.  You could also try to do a few searches
331 on the mailing list for the bug.  Sometimes the bug will have already
332 been reported and a fix or workaround is already known.
333
334 Here is an example of a good bug report:
335
336 @example
337 It seems that placement of accidentals is broken.  In the
338 following example, the accidental touches the note head.
339
340 Using Mac OSX 10.3.5, fink package lilypond-unstable
341
342 \version "2.3.22"
343 \relative c''@{
344    a4 b cis d
345 @}
346 @end example
347
348 @lilypond[quote]
349 \version "2.3.22"
350 \relative c''{
351   \override Accidental #'extra-offset = #'(1.0 . 0)
352   a4 b cis d
353 }
354 @end lilypond
355
356 @node Editor support
357 @section Editor support
358
359 @cindex editors
360 @cindex vim
361 @cindex emacs
362 @cindex modes, editor
363 @cindex syntax coloring
364 @cindex coloring, syntax
365
366 There is support from different editors for LilyPond.
367
368 @table @asis
369 @item Emacs
370 Emacs has a @file{lilypond-mode}, which provides keyword
371 autocompletion, indentation, LilyPond specific parenthesis matching
372 and syntax coloring, handy compile short-cuts and reading LilyPond
373 manuals using Info.  If @file{lilypond-mode} is not installed on your
374 platform, then read the
375 @ifhtml
376 @uref{../../../topdocs/out-www/INSTALL.html,installation instructions}.
377 @end ifhtml
378 @ifnothtml
379 installation instructions.
380 @end ifnothtml
381
382 @item VIM
383
384 For @uref{http://@/www@/.vim@/.org,VIM}, a @file{vimrc} is supplied, along
385 with syntax coloring tools.  For more information, refer to the
386 @ifhtml
387 @uref{../../../topdocs/out-www/INSTALL.html,installation instructions}.
388 @end ifhtml
389 @ifnothtml
390 installation instructions.
391 @end ifnothtml
392
393
394 @item JEdit
395
396 The @uref{http://@/www@/.jedit@/.org/,jEdit} editor has a LilyPond plugin.
397 This plugin includes a DVI viewer, integrated help and viewing via
398 GhostScript.  It can be installed by doing @key{Plugins > Plugin
399 Manager}, and selecting @code{LilyTool} from the @key{Install} tab.
400
401 @end table
402
403 All these editors can be made to jump into the input file to the source
404 of a symbol in the graphical output.  See @ref{Point and click}.
405
406
407
408
409 @node Invoking lilypond-latex
410 @section Invoking lilypond-latex
411
412 Before LilyPond 2.4, the @code{lilypond} program only generated music
413 notation.  Titles and page layout was done in a separate wrapper
414 program.  For compatibility with older files, this wrapper program has
415 been retained as @code{lilypond-latex}.  It uses the LilyPond program
416 and La@TeX{} to create a nicely titled piece of sheet music.  Use of
417 this program is only necessary if the input file contains special
418 La@TeX{} options or formatting codes in markup texts.
419
420 The @code{lilypond-latex} wrapper is invoked from the command-line as
421 follows
422 @example
423 @code{lilypond-latex} [@var{option}]@dots{} @var{file}@dots{}
424 @end example
425
426 To have @code{lilypond-latex} read from stdin, use a dash (@code{-}) for
427 @var{file}.  The program supports the following options.
428
429 @cindex stdin, reading
430
431 @table @code
432 @item -k,--keep
433 Keep the temporary directory with all output files.  The temporary
434 directory is created in the current directory as @code{@code{lilypond}.dir}.
435
436 @item -h,--help
437 Print usage help.
438
439 @item -I,--include=@var{dir}
440 Add @var{dir} to LilyPond's include path.
441
442 @item -o,--output=@var{file}
443 Generate output to @var{file}.  The extension of @var{file} is ignored.
444
445 @item --png
446 Also generate pictures of each page, in PNG format.
447
448 @item --preview
449 Also generate a picture of the first system of the score.
450
451 @cindex preview
452 @cindex picture
453 @cindex bitmap
454 @cindex pixmap
455 @cindex thumbnail
456 @cindex screen shot
457
458 @item -s,--set=@var{key}=@var{val}
459 Add @var{key}= @var{val} to the settings, overriding those specified
460 in the files.  Possible keys: @code{language}, @code{latexheaders},
461 @code{latexpackages}, @code{latexoptions}, @code{papersize},
462 @code{linewidth}, @code{orientation},
463 @code{textheight}.
464
465 @item -v,--version
466 Show version information.
467
468 @item -V,--verbose
469 Be verbose.  This prints out commands as they are executed, and more
470 information about the formatting process is printed.
471
472 @item --debug
473 Print even more information.  This is useful when generating bug reports.
474
475 @item -w,--warranty
476 Show the warranty with which GNU LilyPond comes. (It comes with
477 @strong{NO WARRANTY}!)
478 @end table
479
480
481 @subsection Additional parameters
482
483 The @code{lilypond} program responds to several parameters specified
484 in a @code{\layout} section of the input file.  They can be overridden
485 by supplying a @code{--set} command line option.
486
487 @table @code
488 @item language
489 Specify La@TeX{} language: the @code{babel} package will be
490 included.  Default: unset.
491
492 Read from the @code{\header} block.
493
494 @item latexheaders
495 Specify additional La@TeX{} header files.
496 Normally read from the @code{\header} block.  Default value: empty.
497
498 @item latexpackages
499 Specify additional La@TeX{} package files.  This works cumulative,
500 so you can add multiple packages using multiple @code{-s=latexpackages} options.
501 Normally read from the @code{\header} block.  Default value:
502 @code{geometry}.
503
504 @item latexoptions
505 Specify additional options for the La@TeX{}
506 @code{\documentclass}.  You can put any valid value here.  This was
507 designed to allow @code{lilypond} to produce output for double-sided
508 paper, with balanced margins and page numbers on alternating sides.  To
509 achieve this specify @code{twoside}.
510
511 @item orientation
512 Set orientation.  Choices are @code{portrait} or @code{landscape}.  Is
513 read from the @code{\layout} block, if set.
514
515 @item textheight
516 The vertical extension of the music on the page.  It is normally
517 calculated automatically, based on the paper size.
518
519 @item linewidth
520 The music line width.  It is normally read from the @code{\layout}
521 block.
522
523 @item papersize
524 The paper size (as a name, e.g., @code{a4}).  It is normally read from
525 the @code{\layout} block.
526
527 @item fontenc
528 The font encoding, should be set identical to the @code{font-encoding}
529 property in the score.
530 @end table