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