Skip to content

Commit 5e90de2

Browse files
authored
Merge pull request #3681 from patrickbkr/update-running-rakudo
Rename and update Programs/03-environment-variables.pod6
2 parents 9042335 + 1dc02c0 commit 5e90de2

File tree

1 file changed

+128
-35
lines changed

1 file changed

+128
-35
lines changed

doc/Programs/03-environment-variables.pod6

Lines changed: 128 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,87 @@
11
=begin pod :kind("Programs") :subkind("programs") :category("programs")
22
3-
=TITLE Shell environment variables used by Raku
3+
=TITLE Running Rakudo
44
5-
=SUBTITLE The variables you can declare to alter its behavior or gather
6-
additional information.
5+
=SUBTITLE How to run Rakudo, a Raku implementation, and modify its behavior
6+
with environment variables.
77
8-
The behavior of L<Rakudo|https://rakudo.org>, the Raku interpreter, can be
9-
tweaked by a (growing) number of environment variables; this section attempts to
10-
document all those currently in use. They are interpreter specific in all cases,
11-
except where some use conventional names such as C<PATH>.
8+
=head1 NAME
9+
10+
raku - Rakudo Raku Compiler
11+
12+
=head1 SYNOPSIS
13+
14+
raku [switches] [--] [programfile] [arguments]
15+
16+
=head1 DESCRIPTION
17+
18+
With no arguments, enters a REPL. With a C<[programfile]> or the C<-e>
19+
option, compiles the given program and by default also executes the
20+
compiled code.
21+
22+
-c check syntax only (runs BEGIN and CHECK blocks)
23+
--doc extract documentation and print it as text
24+
-e program one line of program, strict is enabled by default
25+
-h, --help display this help text
26+
-n run program once for each line of input
27+
-p same as -n, but also print $_ at the end of lines
28+
-I path adds the path to the module search path
29+
-M module loads the module prior to running the program
30+
--target=[stage] specify compilation stage to emit
31+
--optimize=[level] use the given level of optimization (0..3)
32+
--encoding=[mode] specify string encoding mode
33+
-o, --output=[name] specify name of output file
34+
-v, --version display version information
35+
--stagestats display time spent in the compilation stages
36+
--ll-exception display a low level backtrace on errors
37+
--profile write profile information as HTML file (MoarVM)
38+
--profile-filename provide a different filename (also allows .json)
39+
--doc=[module] Use Pod::To::[module] to render inline documentation.
40+
--full-cleanup try to free all memory and exit cleanly (MoarVM)
41+
--debug-port=port listen for incoming debugger connections (MoarVM)
42+
--debug-suspend pause execution at the entry point (MoarVM)
43+
--tracing output a line to stderr on every interpreter instr (only
44+
if enabled in MoarVM)
45+
46+
Note that only boolean single-letter options may be bundled.
47+
48+
The supported values for C<--target> are:
49+
50+
Target Backend Description
51+
====== ======= ===========
52+
parse all a representation of the parse tree
53+
ast all an abstract syntax tree (before optimizations)
54+
optimize all an abstract syntax tree (after optimizations)
55+
56+
mbc MoarVM MoarVM byte code
57+
jar JVM JVM archive
58+
59+
For C<--profile-filename>, specifying a name ending in C<.json> will write a raw
60+
JSON profile dump. The default if this is omitted is C<profile-I<[timestamp]>.html>.
61+
62+
=head1 ENVIRONMENT VARIABLES
63+
64+
Rakudo's behavior can be tweaked by a (growing) number of environment variables;
65+
this section attempts to document all those currently in use. They are
66+
interpreter specific in all cases, except where some use conventional names
67+
such as C<PATH>.
1268
1369
The underlying virtual machine is also sensitive to a series of environment
1470
variables; they are listed L<in this wiki
1571
page|https://github.com/rakudo/rakudo/wiki/dev-env-vars#moarvm>.
1672
1773
=head2 Module loading
1874
19-
X<|RAKUDOLIB>X<|PERL6LIB>
20-
=item C<RAKUDOLIB>, C<PERL6LIB>
75+
X<|RAKUDOLIB>X<|RAKULIB>X<|PERL6LIB>
76+
=item C<RAKUDOLIB>, C<RAKULIB> (I<Str>; F<src/core/Inc.pm>)
2177
22-
C<RAKUDOLIB> and C<PERL6LIB> append a comma-delimited list of paths to the
23-
search list for modules. C<RAKUDOLIB> is evaluated first.
78+
C<RAKUDOLIB> and C<RAKULIB> append a comma-delimited list of paths to the
79+
search list for modules. C<RAKUDOLIB> is evaluated first. B<NOTE:> These env
80+
vars were added in the Rakudo compiler in version 2020.05. The deprecated older
81+
env var C<PERL6LIB> is still available.
2482
2583
X<|RAKUDO_MODULE_DEBUG>
26-
=item C<RAKUDO_MODULE_DEBUG>
84+
=item C<RAKUDO_MODULE_DEBUG> (I<Bool>; F<src/Perl6/ModuleLoader.nqp>)
2785
2886
If true, causes the module loader to print debugging information to standard
2987
error.
@@ -37,46 +95,50 @@ X<|PERL6_EXCEPTIONS_HANDLER>
3795
If present, the C<print_exception> routine
3896
will use a class of that name to process the exception for output. Rakudo
3997
currently ships with C<Exceptions::JSON> (invoked by setting this variable to
40-
C<JSON>), to override the default output. B<NOTE:> this env var was added in
98+
C<JSON>), to override the default output. B<NOTE:> This env var was added in
4199
version 6.e. Early implementation has been available in Rakudo compiler
42100
as of version 2019.12, and before that it was available as
43101
C<PERL6_EXCEPTIONS_HANDLER>.
44102
45103
X<|RAKUDO_NO_DEPRECATIONS>
46-
=item C<RAKUDO_NO_DEPRECATIONS>
104+
=item C<RAKUDO_NO_DEPRECATIONS> (I<Bool>; F<src/core.c/Deprecations.pm6>)
47105
48106
If true, suppresses deprecation warnings triggered by the C<is DEPRECATED>
49107
trait.
50108
51109
X<|RAKUDO_DEPRECATIONS_FATAL>
52-
=item C<RAKUDO_DEPRECATIONS_FATAL>
110+
=item C<RAKUDO_DEPRECATIONS_FATAL> (I<Bool>; F<src/core.c/Deprecations.pm6>)
53111
54112
If true, deprecation warnings become thrown exceptions.
55113
56114
X<|RAKUDO_VERBOSE_STACKFRAME>
57-
=item C<RAKUDO_VERBOSE_STACKFRAME>
115+
=item C<RAKUDO_VERBOSE_STACKFRAME> (I<UInt>; F<src/core.c/Backtrace.pm6>)
58116
59117
Displays source code in stack frames surrounded by the specified number of
60118
lines of context; for instance C<RAKUDO_VERBOSE_STACKFRAME = 1> will use one
61119
context line.
62120
63121
X<|RAKUDO_BACKTRACE_SETTING>
64-
=item C<RAKUDO_BACKTRACE_SETTING>
122+
=item C<RAKUDO_BACKTRACE_SETTING> (I<Bool>; F<src/core.c/Backtrace.pm6>)
65123
66124
Controls whether C<.setting> files are included in backtraces.
67125
68126
=head2 Affecting precompilation
69127
70128
X<|RAKUDO_PREFIX>
71-
=item C<RAKUDO_PREFIX>
129+
=item C<RAKUDO_PREFIX> (I<Str>; F<src/core.c/CompUnit/RepositoryRegistry.pm6>)
72130
73131
When this is set, Rakudo will look for the standard repositories (perl, vendor,
74132
site) in the specified directory. This is intended as an escape hatch for
75133
build-time bootstrapping issues, where Rakudo may be built as an unprivileged
76134
user without write access to the runtime paths in NQP's config.
77135
78-
X<|RAKUDO_PRECOMP_DIST>X<|RAKUDO_PRECOMP_LOADING>X<|RAKUDO_PRECOMP_WITH>
79-
=item C<RAKUDO_PRECOMP_DIST>, C<RAKUDO_PRECOMP_LOADING> C<RAKUDO_PRECOMP_WITH>:
136+
X<|RAKUDO_PRECOMP_DIST>
137+
=item C<RAKUDO_PRECOMP_DIST> (F<src/core.c/CompUnit/PrecompilationRepository.pm6>)
138+
X<|RAKUDO_PRECOMP_LOADING>
139+
=item C<RAKUDO_PRECOMP_LOADING> (F<src/core.c/CompUnit/PrecompilationRepository.pm6>)
140+
X<|RAKUDO_PRECOMP_WITH>
141+
=item C<RAKUDO_PRECOMP_WITH> (F<src/core.c/CompUnit/PrecompilationRepository.pm6>)
80142
81143
These are internal variables for passing serialized state to precompilation jobs
82144
in child processes. Please do not set them manually.
@@ -114,24 +176,25 @@ C<~/.perl6/rakudo-history>.
114176
X<|RAKUDO_DEFAULT_READ_ELEMS>
115177
=item C<RAKUDO_DEFAULT_READ_ELEMS>
116178
117-
This specifies the default number of characters to read on an L«C<IO::Handle>|/type/IO::Handle» by
118-
setting the L«C<$*DEFAULT-READ-ELEMS>|/language/variables#$*DEFAULT-READ-ELEMS»
119-
dynamic variable.
179+
This specifies the default number of characters to read on an
180+
L«C<IO::Handle>|/type/IO::Handle» by setting the
181+
L«C<$*DEFAULT-READ-ELEMS>|/language/variables#$*DEFAULT-READ-ELEMS» dynamic
182+
variable.
120183
121184
X<|RAKUDO_ERROR_COLOR>
122-
=item C<RAKUDO_ERROR_COLOR>
185+
=item C<RAKUDO_ERROR_COLOR> (I<Bool>; F<src/core.c/Exception.pm6>)
123186
124187
Controls whether to emit ANSI codes for error highlighting. Defaults to true
125188
if unset, except on Windows.
126189
127190
X<|RAKUDO_MAX_THREADS>
128-
=item C<RAKUDO_MAX_THREADS>
191+
=item C<RAKUDO_MAX_THREADS> (I<UInt>; F<src/core.c/ThreadPoolScheduler.pm6>)
129192
130193
Indicates the maximum number of threads used by default when creating a
131-
C<ThreadPoolScheduler>. Defaults to 64.
194+
C<ThreadPoolScheduler>. Defaults to 64.
132195
133196
X<|TMPDIR>X<|TEMP>X<|TMP>
134-
=item C<TMPDIR>, C<TEMP>, C<TMP>:
197+
=item C<TMPDIR>, C<TEMP>, C<TMP> (I<Str>; F<src/core.c/IO/Spec/>)
135198
136199
The C<IO::Spec::Unix.tmpdir> method will return C<$TMPDIR> if it points to a
137200
directory with full access permissions for the current user, with a fallback
@@ -141,7 +204,7 @@ C<IO::Spec::Cygwin> and C<IO::Spec::Win32> use more Windows-appropriate lists
141204
which also include the C<%TEMP%> and C<%TMP%> environment variables.
142205
143206
X<|PATH>
144-
=item C<PATH>, C<Path>
207+
=item C<PATH>, C<Path> (I<Str>; F<src/core.c/IO/Spec/>)
145208
146209
The C<IO::Spec::Unix.path> method splits C<$PATH> as a
147210
shell would; i.e. as a colon-separated list. C<IO::Spec::Cygwin> inherits this
@@ -154,15 +217,45 @@ X<|RAKUDO_SNAPPER>
154217
Indicates the period in which the telemetry snapper will take a snapshot.
155218
Defaults to .1 for 10 snapshots per second.
156219
157-
=head1 AUTHORS
220+
X<|RAKUDO_HOME>
221+
=item C<RAKUDO_HOME>
222+
223+
Allows to override the Raku installation path. Defaults to
224+
C<[rakudo_executable_dir]/../share/perl6> in relocatable builds and the
225+
absolute path to that folder in non-relocatable builds.
226+
227+
X<|NQP_HOME>
228+
=item C<NQP_HOME>
229+
230+
Allows to override the NQP installation path. Defaults to
231+
C<[rakudo_executable_dir]/../share/nqp> in relocatable builds and the absolute
232+
path to that folder in non-relocatable builds.
233+
234+
=head1 WINDOWS PECULIARITIES
235+
236+
X<|rakuw.exe>X<|rakudow.exe>
237+
=head2 Non-console applications
158238
159-
Initial version written by the Rakudo contributors, see the
160-
L<CREDITS file|https://github.com/rakudo/rakudo/blob/master/CREDITS>.
239+
On Windows programs are compiled to either be I<console> applications or
240+
I<non-console> applications. I<Console> applications always open a console
241+
window. There is no straightforward way to suppress this window.
242+
243+
Rakudo provides a separate set of executables suffixed with a C<'w'>
244+
(C<rakuw.exe>, C<rakudow.exe>, ...) that are compiled as I<non-console>
245+
applications. These do not spawn this console window.
246+
247+
B<WARNING> By default these I<non-console> applications will silently swallow
248+
everything that is printed to C<STDOUT> and C<STDERR>.
249+
250+
To receive the output of the program it suffices to redirect it externally:
251+
252+
rakuw.exe script.raku >stdout.txt 2>stderr.txt
253+
254+
=head1 AUTHORS
161255
162-
The L<initial version of this manual
163-
page|https://github.com/rakudo/rakudo/blob/master/docs/running.pod> was written
164-
by Reini Urban, Moritz Lenz and the Rakudo contributors.
256+
Written by the Rakudo contributors, see the CREDITS file.
165257
166-
=end pod
258+
This manual page was written by Reini Urban, Moritz Lenz and the Rakudo
259+
contributors.
167260
168261
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6

0 commit comments

Comments
 (0)