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