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