]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/invoking.itely
Misc small changes.
[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 * Updating files with convert-ly::
12 * Reporting bugs::
13 * Editor support::
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, either the
137 @code{--safe} or the @code{--jail} option @b{MUST} be passed.  The
138 @code{--safe} option will prevent inline Scheme code from wreaking
139 havoc, for example
140
141 When LilyPond formatting is available through a web server, the
142 @code{--safe} @b{MUST} be passed.  This will prevent inline Scheme
143 code from wreaking havoc, for example
144
145 @quotation
146 @verbatim
147 #(system "rm -rf /")
148 {
149   c4^#(ly:export (ly:gulp-file "/etc/passwd"))
150 }
151 @end verbatim
152 @end quotation
153
154 The @code{--safe} option works by evaluating in-line Scheme
155 expressions in a special safe module.  This safe module is derived from
156 GUILE @file{safe-r5rs} module, but adds a number of functions of the
157 LilyPond API.  These functions are listed in @file{scm/@/safe@/-lily@/.scm}.
158
159 In addition, @code{--safe} disallows @code{\include} directives and
160 disables the use of backslashes in @TeX{} strings.
161
162 In @code{--safe} mode, it is not possible to import LilyPond variables
163 into Scheme.
164
165 @code{--safe} does @emph{not} detect resource overuse.  It is still
166 possible to make the program hang indefinitely, for example by feeding
167 cyclic data structures into the backend.  Therefore, if using LilyPond
168 on a publicly accessible webserver, the process should be limited in
169 both CPU and memory usage.
170
171 Note that @code{--safe} will prevent many useful LilyPond snippets from
172 being compiled.  For a softer but secure alternative you can use the
173 @code{--jail} option.
174
175
176 @item -j,--jail=@var{user},@var{group},@var{jail},@var{dir}
177 Run LilyPond in a jail.
178
179 The @code{--jail} option provides a more flexible alternative to 
180 @code{--safe} when LilyPond formatting is available through a web
181 server or whenever LilyPond executes externally provided
182 sources.
183
184 The @code{--jail} option works by changing the root of LilyPond to
185 @var{jail} just before starting the actual compilation process.  The user
186 and group are then changed to match those provided, and the current
187 directory is changed to @var{dir}.  This setup guarantees that it is not
188 possible (at least in theory) to escape from the jail.  Note that for
189 @code{--jail} to work LilyPond must be run as root, which is usually
190 accomplished in a safe way using @command{sudo}.
191
192 Setting up a jail is a slightly delicate matter, as we must be sure that
193 LilyPond is able to find whatever it needs to compile the source
194 @emph{inside the jail}. A typical setup comprises the following items:
195
196 @table @asis
197 @item Setting up a separate filesystem
198 A separate filesystem should be created for LilyPond, so that it can be
199 mounted with safe options such as @code{noexec}, @code{nodev}, and
200 @code{nosuid}.  In this way, it is impossible to run executables or to
201 write directly to a device from LilyPond.  If you do not want to create a
202 separate partition, just create a file of reasonable size and use it to
203 mount a loop device.  A separate filesystem also guarantees that LilyPond
204 cannot write more space than it is allowed.
205
206 @item Setting up a separate user
207 A separate user and group (say, @samp{lily}/@samp{lily}) with low
208 privileges should be used to run LilyPond inside the jail.  There should
209 be a single directory writable by this user, which should be passed in
210 @var{dir}.
211
212 @item Preparing the jail
213 LilyPond needs to read a number of files while running.  All these files
214 are to be copied into the jail, under the same path they apper in the
215 real root filesystem.  The entire content of the LilyPond installation
216 (e.g., @file{/usr/share/lilypond})
217 should be copied.
218
219 @ignore
220 FIXME:  fact-check; delete very soon.  -gp
221 , and the content of the @file{fonts},
222 @file{dvips} and @file{web2c} directories of the @TeX{} installation
223 (usually under @file{/usr/share/texmf}) should be copied, too.  If your
224 @TeX{} installation uses @file{ls-R} caches, copy also the cache inside the root
225 of the installation.
226 @end ignore
227
228 If problems arise, the simplest way to trace them down is to run
229 LilyPond using @command{strace}, which will allow you to determine which
230 files are missing.
231
232 @item Running LilyPond
233 In a jail mounted with @code{noexec} it is impossible to execute any external
234 program.  Therefore LilyPond must be run with a backend that does not
235 require any such program.  As we already mentioned, it must be also run
236 with superuser privileges (which, of course, it will lose immediately),
237 possibly using @command{sudo}.  It is a good idea to limit the number of
238 seconds of CPU time LilyPond can use (e.g., using @command{ulimit
239 -t}), and, if your operating system supports it, the amount of memory
240 that can be allocated.
241 @end table
242
243
244 @item -v,--version
245 Show version information.
246
247 @item -V,--verbose
248 Be verbose: show full paths of all files read, and give timing
249 information.
250
251 @item -w,--warranty
252 Show the warranty with which GNU LilyPond comes. (It comes with
253 @strong{NO WARRANTY}!)
254 @end table
255
256
257 @section Environment variables
258
259 For processing both the @TeX{} and the PostScript output, the
260 appropriate environment variables must be set.  The following scripts
261 do this:
262
263 @itemize @bullet
264 @item @file{buildscripts/@/out/@/lilypond@/-profile}
265 (for SH shells)
266 @item @file{buildscripts/@/out/@/lilypond@/-login} (for C-shells)
267 @end itemize
268
269 They should normally be sourced as part of the login process.  If these
270 scripts are not run from the system wide login process, then you must
271 run them yourself.
272
273 @cindex installing LilyPond
274
275 If you use sh, bash, or a similar shell, then add the following to
276 your @file{.profile}:
277 @example
278 . @var{/the/path/to/}lilypond-profile
279 @end example
280
281 If you use csh, tcsh or a similar shell, then add the following to
282 your @file{~/.login}:
283 @example
284 source @var{/the/path/to/}lilypond-login
285 @end example
286
287 Of course, in both cases, you should substitute the proper location of
288 either script.
289
290 These scripts set the following variables:
291 @table @code
292 @item TEXMF
293 To make sure that @TeX{} and lilypond find data files (among
294 others @file{.tex}, @file{.mf}, and @file{.tfm}),
295 you have to set @code{TEXMF} to point to the lilypond data
296 file tree.  A typical setting would be
297 @example
298 @{/usr/share/lilypond/2.4.0,@{!!/usr/share/texmf@}@}
299 @end example
300
301 @end table
302
303
304 @cindex PostScript
305 @cindex TEXMF
306 @cindex printing postscript
307
308 The binary itself recognizes the following environment variables:
309 @table @code
310 @item LILYPONDPREFIX
311 This specifies a directory where locale messages and
312 data files will be looked up by default.  The directory should contain
313 subdirectories called @file{ly/}, @file{ps/}, @file{tex/}, etc.
314
315 @item LANG
316 This selects the language for the warning messages.
317 @end table
318
319 @cindex LANG
320 @cindex LILYPONDPREFIX
321
322 @node Error messages
323 @section Error messages
324
325 @cindex error messages
326 Different error messages can appear while compiling a file:
327
328 @table @emph
329 @cindex warning
330
331 @item Warning
332 Something looks suspect.  If you are requesting something out of the
333 ordinary then you will understand the message, and can ignore it.
334 However, warnings usually indicate that something is wrong with the
335 input file.
336
337 @item Error
338 Something is definitely wrong.  The current processing step (parsing,
339 interpreting, or formatting) will be finished, but the next step will
340 be skipped.
341
342 @cindex error
343 @cindex fatal error
344 @item Fatal error
345 Something is definitely wrong, and LilyPond cannot continue.  This
346 happens rarely.  The most usual cause is misinstalled fonts.
347
348 @cindex trace, Scheme
349 @cindex call trace
350 @cindex Scheme error
351 @item Scheme error
352 Errors that occur while executing Scheme code are caught by the Scheme
353 interpreter.  If running with the verbose option (@code{-V} or
354 @code{--verbose}) then a call trace of the offending
355 function call is printed.
356
357 @cindex Programming error
358 @item Programming error
359 There was some internal inconsistency.  These error messages are
360 intended to help the programmers and debuggers.  Usually, they can be
361 ignored.  Sometimes, they come in such big quantities that they obscure
362 other output.  In this case, file a bug-report.
363
364 @item Aborted (core dumped)
365 This signals a serious programming error that caused the program to
366 crash.  Such errors are considered critical.  If you stumble on one,
367 send a bug-report.
368
369
370 @end table
371
372 @cindex errors, message format
373 If warnings and errors can
374 be linked to some part of the input file, then error messages have the
375 following form
376
377 @example
378 @var{filename}:@var{lineno}:@var{columnno}: @var{message}
379 @var{offending input line}
380 @end example
381
382 A line-break is inserted in the offending line to indicate the column
383 where the error was found.  For example,
384
385 @example
386 test.ly:2:19: error: not a duration: 5:
387   @{ c'4 e'5
388              g' @}
389 @end example
390
391 These locations are LilyPond's best guess about where the warning or
392 error occured, but (by their very nature) warnings and errors occur
393 when something unexpected happens.  If you can't see an error in the
394 indicated line of your input file, try checking one or two lines
395 above the indicated position.
396
397
398 @node Updating files with convert-ly
399 @section Updating with @command{convert-ly}
400
401 The LilyPond input syntax is routinely changed to simplify it or improve
402 it in different ways.  As a side effect of this, the LilyPond interpreter
403 often is no longer compatible with older input files.  To remedy this,
404 the program @command{convert-ly} can be used to deal with most of the
405 syntax changes between LilyPond versions.
406
407 It uses @code{\version} statements in the input files to detect the old
408 version number.  In most cases, to upgrade your input file it is sufficient
409 to run
410
411 @example
412 convert-ly -e myfile.ly
413 @end example
414
415 If there are no changes to myfile.ly and file called myfile.ly.NEW
416 is created, then myfile.ly is already updated.
417
418 To upgrade LilyPond fragments in texinfo files, use
419
420 @example
421 convert-ly --from=... --to=... --no-version *.itely
422 @end example
423
424 To upgrade many files at once, combine @code{convert-ly} with
425 standard unix commands.  This example will upgrade all @code{.ly}
426 files in the current directory
427
428 @example
429 for f in *.ly; do convert-ly -e $f; done;
430 @end example
431
432 In general, the program is invoked as follows:
433
434 @example
435 convert-ly [@var{option}]@dots{} @var{file}@dots{}
436 @end example
437
438
439 The following options can be given:
440
441 @table @code
442 @item -e,--edit
443 Do an inline edit of the input file.  Overrides @code{--output}.
444
445 @item -f,--from=@var{from-patchlevel}
446 Set the version to convert from.  If this is not set, @command{convert-ly}
447 will guess this, on the basis of @code{\version} strings in the file.
448
449 @item -o,--output=@var{file}
450 Set the output file to write.  
451
452 @item -n,--no-version
453 Normally, @command{convert-ly} adds a @code{\version} indicator 
454 to the output.  Specifying this option suppresses this.  
455
456 @item -s, --show-rules
457 Show all known conversions and exit.
458
459 @item --to=@var{to-patchlevel}
460 Set the goal version of the conversion.  It defaults to the latest
461 available version.
462
463 @item -h, --help
464 Print usage help.
465 @end table
466
467 @command{convert-ly} always converts up to the last syntax change handled by
468 it.  This means that the @code{\version} number left in the file is
469 usually lower than the version of @command{convert-ly} itself.
470
471 @refbugs
472
473 Not all language changes are handled.  Only one output option can be
474 specified.
475
476
477 @c  We might want to make this a completely new section, along with more
478 @c  info about how to upgrade old input files.  -gp
479
480 @ignore
481 Copy and paste from CVS, last updated
482 Feb 14, 2005
483
484 http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/lilypond/lily-bugs/bugs/convert-ly.txt?rev=HEAD&content-type=text/plain
485 @end ignore
486 @verbatim
487
488 There are a few things that the convert-ly cannot handle.  Here's a list of limitations
489 that the community has complained about.
490
491 This bug report structure has been chosen because convert-ly has a structure that doesn't
492 allow to smoothly implement all needed changes.  Thus this is just a wishlist, placed
493 here for reference.
494
495 1.6->2.0:
496  Doesn't always convert figured bass correctly, specifically things like {< >}. Mats' comment on working around this:
497    To be able to run convert-ly
498    on it, I first replaced all occurencies of '{<' to some dummy like '{#'
499    and similarly I replaced '>}' with '&}'. After the conversion, I could
500    then change back from '{ #' to '{ <' and from '& }' to '> }'.
501  Doesn't convert all text markup correctly. Only very simple cases are fixed.
502 2.0->2.2:
503  Doesn't handle \partcombine
504  Doesn't do \addlyrics => \lyricsto, this breaks some scores with multiple stanzas.
505 2.2->2.4:
506  \turnOff (used in \set Staff.VoltaBracket = \turnOff) is not properly converted.
507 2.4.2->2.5.9
508  \markup{ \center-align <{ ... }> } should be converted to:
509  \markup{ \center-align {\line { ... }} }
510  but now, \line is missing.
511 @end verbatim
512
513
514 @node Reporting bugs
515 @section Reporting bugs
516
517 @cindex bugs
518 @cindex reporting bugs
519
520 If you have input that results in a crash or an erroneous output, then
521 that is a bug.  We try to respond to bug-reports promptly, and fix them as
522 soon as possible.  Help us by sending a defective input file, so we can
523 reproduce the problem.  Make it small, so we can easily debug the
524 problem.  Don't forget to tell which version of LilyPond you use!  Send
525 the report to @email{bug-lilypond@@gnu.org}.
526
527 When you've found a bug, have a look at our
528 @uref{http://@/lilypond@/.org/@/doc/@/v2.3/@/bugs/,bug database} to see if
529 it has already been reported.  You could also try to do a few searches
530 on the mailing list for the bug.  Sometimes the bug will have already
531 been reported and a fix or workaround is already known.
532
533 Here is an example of a good bug report:
534
535 @example
536 It seems that placement of accidentals is broken.  In the
537 following example, the accidental touches the note head.
538
539 Using Mac OSX 10.3.5, fink package lilypond-unstable
540
541 \version "2.3.22"
542 \relative c''@{
543    a4 b cis d
544 @}
545 @end example
546
547 @lilypond[quote]
548 \version "2.3.22"
549 \relative c''{
550   \override Accidental #'extra-offset = #'(1.0 . 0)
551   a4 b cis d
552 }
553 @end lilypond
554
555 @node Editor support
556 @section Editor support
557
558 @cindex editors
559 @cindex vim
560 @cindex emacs
561 @cindex modes, editor
562 @cindex syntax coloring
563 @cindex coloring, syntax
564
565 There is support from different editors for LilyPond.
566
567 @table @asis
568 @item Emacs
569 Emacs has a @file{lilypond-mode}, which provides keyword
570 autocompletion, indentation, LilyPond specific parenthesis matching
571 and syntax coloring, handy compile short-cuts and reading LilyPond
572 manuals using Info.  If @file{lilypond-mode} is not installed on your
573 platform, then read the
574 @ifhtml
575 @uref{../../../topdocs/out-www/INSTALL.html,installation instructions}.
576 @end ifhtml
577 @ifnothtml
578 installation instructions.
579 @end ifnothtml
580
581 @item VIM
582
583 For @uref{http://@/www@/.vim@/.org,VIM}, a @file{vimrc} is supplied, along
584 with syntax coloring tools.  For more information, refer to the
585 @ifhtml
586 @uref{../../../topdocs/out-www/INSTALL.html,installation instructions}.
587 @end ifhtml
588 @ifnothtml
589 installation instructions.
590 @end ifnothtml
591
592
593 @item JEdit
594
595 The @uref{http://@/www@/.jedit@/.org/,jEdit} editor has a LilyPond plugin.
596 This plugin includes a DVI viewer, integrated help and viewing via
597 GhostScript.  It can be installed by doing @key{Plugins > Plugin
598 Manager}, and selecting @code{LilyTool} from the @key{Install} tab.
599
600 @end table
601
602 All these editors can be made to jump into the input file to the source
603 of a symbol in the graphical output.  See @ref{Point and click}.
604
605