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