]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/application/running.itely
Merge branch 'lilypond/translation' of ssh://jomand@git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / Documentation / application / running.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2
3 @ignore
4     Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
5
6     When revising a translation, copy the HEAD committish of the
7     version that you are working on.  See TRANSLATION for details.
8 @end ignore
9
10 @c \version "2.12.0"
11
12
13 @node Running lilypond
14 @chapter Running @command{lilypond}
15
16 This chapter details the technicalities of running LilyPond.
17
18 @menu
19 * Normal usage::
20 * Command-line usage::
21 * Error messages::
22 @end menu
23
24
25 @node Normal usage
26 @section Normal usage
27
28 Most users run LilyPond through a GUI; see @rlearning{First steps}
29 if you have not read this already.
30
31
32 @node Command-line usage
33 @section Command-line usage
34
35 This section contains extra information about using LilyPond on the
36 command-line.  This may be desirable to pass extra options to the
37 program.  In addition, there are certain extra @q{helper} programs (such
38 as @code{midi2ly}) which are only available on the command-line.
39
40 By @q{command-line}, we mean the command line in the operating system.
41 Windows users might be more familiar with the terms @q{DOS shell} or
42 @q{command shell}.  MacOS@tie{}X users might be more familiar with the terms
43 @q{terminal} or @q{console}.  Some additional setup is required
44 for MacOS@tie{}X users; please see @rgeneral{MacOS X}.
45
46 Describing how to use this part of an operating system is outside the
47 scope of this manual; please consult other documentation on this topic
48 if you are unfamiliar with the command-line.
49
50 @menu
51 * Invoking lilypond::
52 * Command line options for lilypond::
53 * Environment variables::
54 @end menu
55
56 @node Invoking lilypond
57 @unnumberedsubsec Invoking @command{lilypond}
58
59 The @command{lilypond} executable may be called as follows from
60 the command line.
61
62 @example
63 lilypond [@var{option}]@dots{} @var{file}@dots{}
64 @end example
65
66
67 When invoked with a filename that has no extension, the @file{.ly}
68 extension is tried first.  To read input from stdin, use a
69 dash (@code{-}) for @var{file}.
70
71 When @file{filename.ly} is processed it will produce @file{filename.ps}
72 and @file{filename.pdf} as output.  Several files can be specified;
73 they will each be processed independently.  @footnote{The status of
74 GUILE is not reset after processing a @code{.ly} file, so be careful
75 not to change any system defaults from within Scheme.}
76
77 If @file{filename.ly} contains more than one @code{\book}
78 block, then the rest of the scores will be output in numbered files,
79 starting with @file{filename-1.pdf}.  In addition, the value of
80 @code{output-suffix} will be inserted between the basename and the
81 number.  An input file containing
82
83 @example
84 #(define output-suffix "violin")
85 \score @{ @dots{} @}
86 #(define output-suffix "cello")
87 \score @{ @dots{} @}
88 @end example
89
90 @noindent
91 will output @var{base}@file{-violin.pdf} and
92 @var{base}@file{-cello-1.pdf}.
93
94
95 @node Command line options for lilypond
96 @unnumberedsubsec Command line options for @command{lilypond}
97
98 @cindex Invoking @command{lilypond}
99 @cindex command line options for @command{lilypond}
100 @cindex options, command line
101 @cindex switches
102
103 The following options are supported:
104
105 @table @code
106
107 @item -e,--evaluate=@var{expr}
108 Evaluate the Scheme @var{expr} before parsing any @file{.ly} files.
109 Multiple @code{-e} options may be given, they will be evaluated
110 sequentially.
111
112 The expression will be evaluated in the @code{guile-user} module, so
113 if you want to use definitions in @var{expr}, use
114
115 @example
116 lilypond -e '(define-public a 42)'
117 @end example
118
119 @noindent
120 on the command-line, and include
121
122 @example
123 #(use-modules (guile-user))
124 @end example
125
126 @noindent
127 at the top of the @code{.ly} file.
128
129 @item -f,--format=@var{format}
130 which formats should be written.  Choices for @code{format} are
131 @code{svg}, @code{ps}, @code{pdf}, and @code{png}.
132
133 Example: @code{lilypond -fpng @var{filename}.ly}
134
135
136
137 @item -d,--define-default=@var{var}=@var{val}
138 This sets the internal program option @var{var} to the Scheme value
139 @var{val}.  If @var{val} is not supplied, then @var{#t} is used.  To
140 switch off an option, @code{no-} may be prefixed to @var{var}, e.g.
141
142 @cindex point and click, command line
143
144 @example
145 -dno-point-and-click
146 @end example
147
148 @noindent
149 is the same as
150 @example
151 -dpoint-and-click='#f'
152 @end example
153
154 Here are a few interesting options.
155
156 @cindex help, command line
157
158 @table @samp
159 @item help
160 Running @code{lilypond -dhelp} will print all of the @code{-d} options
161 available.
162
163 @cindex paper-size, command line
164
165 @item paper-size
166 This option sets the default paper-size,
167 @example
168 -dpaper-size=\"letter\"
169 @end example
170
171 @noindent
172 Note that the string must be enclosed in escaped quotes ( @code{\"} ).
173 @c Match " in previous line to help context-sensitive editors
174
175 @cindex safe, command line
176
177 @item safe
178 Do not trust the @code{.ly} input.
179
180 When LilyPond formatting is available through a web server, either the
181 @code{--safe} or the @code{--jail} option @b{MUST} be passed.  The
182 @code{--safe} option will prevent inline Scheme code from wreaking
183 havoc, for example
184
185 @quotation
186 @verbatim
187 #(system "rm -rf /")
188 {
189   c4^#(ly:export (ly:gulp-file "/etc/passwd"))
190 }
191 @end verbatim
192 @end quotation
193
194 The @code{-dsafe} option works by evaluating in-line Scheme
195 expressions in a special safe module.  This safe module is derived from
196 GUILE @file{safe-r5rs} module, but adds a number of functions of the
197 LilyPond API.  These functions are listed in @file{scm/@/safe@/-lily@/.scm}.
198
199 In addition, safe mode disallows @code{\include} directives and
200 disables the use of backslashes in @TeX{} strings.
201
202 In safe mode, it is not possible to import LilyPond variables
203 into Scheme.
204
205 @code{-dsafe} does @emph{not} detect resource overuse.  It is still possible to
206 make the program hang indefinitely, for example by feeding cyclic data
207 structures into the backend.  Therefore, if using LilyPond on a
208 publicly accessible webserver, the process should be limited in both
209 CPU and memory usage.
210
211 The safe mode will prevent many useful LilyPond snippets from being
212 compiled.  The @code{--jail} is a more secure alternative, but
213 requires more work to set up.
214
215 @cindex output format, setting
216 @item backend
217 the output format to use for the back-end.  Choices for @code{format} are
218 @table @code
219 @item ps
220 @cindex PostScript output
221  for PostScript.
222
223   Postscript files include TTF, Type1 and OTF fonts.  No subsetting of
224   these fonts is done.  When using oriental character sets, this can
225   lead to huge files.
226
227 @item eps
228
229 @cindex Postscript, encapulated
230 @cindex EPS (Encapsulated PostScript)
231
232  for encapsulated PostScript.  This dumps every page (system) as a separate
233 @file{EPS} file, without fonts, and as one collated @file{EPS} file with
234 all pages (systems) including fonts.
235
236 This mode is used by default by @command{lilypond-book}.
237
238 @item svg
239
240 @cindex SVG (Scalable Vector Graphics)
241
242  for SVG (Scalable Vector Graphics).
243
244  This creates a single SVG file, without embedded fonts, for every
245  page of output.  It is recommended to install the Century
246  Schoolbook fonts, included with your LilyPond installation, for
247  optimal rendering.  Under UNIX, simply copy these fonts from the
248  LilyPond directory (typically
249  @file{/usr/share/lilypond/VERSION/fonts/otf/}) to
250  @file{~/.fonts/}.  The SVG output should be compatible with any
251  SVG editor or user agent.
252
253 @item scm
254
255 @cindex Scheme dump
256
257  for a dump of the raw, internal Scheme-based drawing commands.
258
259 @item null
260  do not output a printed score; has the same effect as @code{-dno-print-pages}.
261 @end table
262
263 Example: @code{lilypond -dbackend=svg @var{filename}.ly}
264
265 @item preview
266 @cindex preview, command line
267 Generate an output file containing the titles and the first system
268
269 @item print-pages
270 Generate the full pages, the default.  @code{-dno-print-pages} is
271 useful in combination with @code{-dpreview}.
272
273 @end table
274
275
276
277 @item -h,--help
278 Show a summary of usage.
279
280 @item -H,--header=@var{FIELD}
281 Dump a header field to file @file{BASENAME.@var{FIELD}}.
282
283 @item --include, -I=@var{directory}
284 Add @var{directory} to the search path for input files.
285 @cindex file searching
286 @cindex search path
287
288 @item -i,--init=@var{file}
289 Set init file to @var{file} (default: @file{init.ly}).
290
291 @item -o,--output=@var{FILE}
292 Set the default output file to @var{FILE}.  The appropriate
293 suffix will be added (e.g. @code{.pdf} for pdf)
294
295 @cindex PostScript output
296
297 @item --ps
298 Generate PostScript.
299
300 @cindex Portable Network Graphics (PNG) output
301
302 @item --png
303 Generate pictures of each page, in PNG format.  This implies
304 @code{--ps}.  The resolution in DPI of the image may be set with
305 @example
306 -dresolution=110
307 @end example
308
309 @cindex Portable Document Format (PDF) output
310
311 @item --pdf
312 Generate PDF.  This implies @code{--ps}.
313
314
315
316 @item -j,--jail=@var{user},@var{group},@var{jail},@var{dir}
317 Run @command{lilypond} in a chroot jail.
318
319 The @code{--jail} option provides a more flexible alternative to
320 @code{--safe} when LilyPond formatting is available through a web
321 server or whenever LilyPond executes externally provided
322 sources.
323
324 The @code{--jail} option works by changing the root of @command{lilypond} to
325 @var{jail} just before starting the actual compilation process.  The user
326 and group are then changed to match those provided, and the current
327 directory is changed to @var{dir}.  This setup guarantees that it is not
328 possible (at least in theory) to escape from the jail.  Note that for
329 @code{--jail} to work @command{lilypond} must be run as root, which is usually
330 accomplished in a safe way using @command{sudo}.
331
332 Setting up a jail is a slightly delicate matter, as we must be sure that
333 LilyPond is able to find whatever it needs to compile the source
334 @emph{inside the jail}.  A typical setup comprises the following items:
335
336 @table @asis
337 @item Setting up a separate filesystem
338 A separate filesystem should be created for LilyPond, so that it can be
339 mounted with safe options such as @code{noexec}, @code{nodev}, and
340 @code{nosuid}.  In this way, it is impossible to run executables or to
341 write directly to a device from LilyPond.  If you do not want to create a
342 separate partition, just create a file of reasonable size and use it to
343 mount a loop device.  A separate filesystem also guarantees that LilyPond
344 cannot write more space than it is allowed.
345
346 @item Setting up a separate user
347 A separate user and group (say, @code{lily}/@code{lily}) with low
348 privileges should be used to run LilyPond inside the jail.  There should
349 be a single directory writable by this user, which should be passed in
350 @var{dir}.
351
352 @item Preparing the jail
353 LilyPond needs to read a number of files while running.  All these files
354 are to be copied into the jail, under the same path they appear in the
355 real root filesystem.  The entire content of the LilyPond installation
356 (e.g., @file{/usr/share/lilypond})
357 should be copied.
358
359 If problems arise, the simplest way to trace them down is to run
360 LilyPond using @command{strace}, which will allow you to determine which
361 files are missing.
362
363 @item Running LilyPond
364 In a jail mounted with @code{noexec} it is impossible to execute any external
365 program.  Therefore LilyPond must be run with a backend that does not
366 require any such program.  As we already mentioned, it must be also run
367 with superuser privileges (which, of course, it will lose immediately),
368 possibly using @command{sudo}.  It is a good idea to limit the number of
369 seconds of CPU time LilyPond can use (e.g., using @command{ulimit
370 -t}), and, if your operating system supports it, the amount of memory
371 that can be allocated.
372 @end table
373
374
375 @item -v,--version
376 Show version information.
377
378 @item -V,--verbose
379 Be verbose: show full paths of all files read, and give timing
380 information.
381
382 @item -w,--warranty
383 Show the warranty with which GNU LilyPond comes. (It comes with
384 @strong{NO WARRANTY}!)
385 @end table
386
387 @node Environment variables
388 @unnumberedsubsec Environment variables
389
390
391 @cindex LANG
392 @cindex LILYPOND_DATADIR
393
394 @command{lilypond} recognizes the following environment variables:
395 @table @code
396 @item LILYPOND_DATADIR
397 This specifies a directory where locale messages and
398 data files will be looked up by default.  The directory should contain
399 subdirectories called @file{ly/}, @file{ps/}, @file{tex/}, etc.
400
401 @item LANG
402 This selects the language for the warning messages.
403
404 @item LILYPOND_GC_YIELD
405 With this variable the memory footprint and performance can be
406 adjusted.  It is a percentage tunes memory management behavior.  With
407 higher values, the program uses more memory, with smaller values, it
408 uses more CPU time.  The default value is @code{70}.
409
410 @end table
411
412
413 @node Error messages
414 @section Error messages
415
416 @cindex error messages
417 Different error messages can appear while compiling a file:
418
419 @table @emph
420
421 @item Warning
422 @cindex warning
423 Something looks suspect.  If you are requesting something out of the
424 ordinary then you will understand the message, and can ignore it.
425 However, warnings usually indicate that something is wrong with the
426 input file.
427
428 @item Error
429 @cindex error
430 Something is definitely wrong.  The current processing step (parsing,
431 interpreting, or formatting) will be finished, but the next step will
432 be skipped.
433
434 @item Fatal error
435 @cindex fatal error
436 Something is definitely wrong, and LilyPond cannot continue.  This
437 happens rarely.  The most usual cause is misinstalled fonts.
438
439 @item Scheme error
440 @cindex trace, Scheme
441 @cindex call trace
442 @cindex Scheme error
443 Errors that occur while executing Scheme code are caught by the Scheme
444 interpreter.  If running with the verbose option (@code{-V} or
445 @code{--verbose}) then a call trace of the offending
446 function call is printed.
447
448 @item Programming error
449 @cindex Programming error
450 There was some internal inconsistency.  These error messages are
451 intended to help the programmers and debuggers.  Usually, they can be
452 ignored.  Sometimes, they come in such big quantities that they obscure
453 other output.
454
455 @item Aborted (core dumped)
456 @cindex Aborted (core dumped)
457 This signals a serious programming error that caused the program to
458 crash.  Such errors are considered critical.  If you stumble on one,
459 send a bug-report.
460 @end table
461
462 @cindex errors, message format
463 If warnings and errors can
464 be linked to some part of the input file, then error messages have the
465 following form
466
467 @example
468 @var{filename}:@var{lineno}:@var{columnno}: @var{message}
469 @var{offending input line}
470 @end example
471
472 A line-break is inserted in the offending line to indicate the column
473 where the error was found.  For example,
474
475 @example
476 test.ly:2:19: error: not a duration: 5
477   @{ c'4 e'
478            5 g' @}
479 @end example
480
481 These locations are LilyPond's best guess about where the warning or
482 error occurred, but (by their very nature) warnings and errors occur
483 when something unexpected happens.  If you can't see an error in the
484 indicated line of your input file, try checking one or two lines
485 above the indicated position.
486
487 More information about errors is given in @ref{Common errors}.
488
489