Running rakudo from the command line

Juan Julián Merelo Guervós edited this page Feb 9, 2018 · 1 revision


perl6 [switches] [--] [programfile] [arguments]


With no arguments, enters a REPL (see --repl-mode option). With a "[programfile]" or the "-e" option, compiles the given program and, by default, also executes the compiled code.

Option               Purpose
======               ==============================================
-c                   check syntax only (runs BEGIN and CHECK blocks)
--doc                extract documentation and print it as text
-e program           one line of program, strict is enabled by default
-h, --help           display this help text
-n                   run program once for each line of input
-p                   same as -n, but also print $_ at the end of lines
-I path              adds the path to the module search path
-M module            loads the module prior to running the program
--target=stage       specify compilation stage to emit
--optimize=level     use the given level of optimization (0..3)
--encoding=mode      specify string encoding mode
-o, --output=name    specify name of output file
-v, --version        display version information
--stagestats         display time spent in the compilation stages
--ll-exception       display a low level backtrace on errors
--profile[=kind]     write profile information to an HTML file (MoarVM)
                       instrumented - performance measurements (default)
                       heap - record heap snapshots after every
                              garbage collector run
                     provide a different filename for profile. Extension
                     controls format:
                          .json outputs in JSON
                          .sql  outputs in SQL
                          any other extension outputs in HTML
--doc=module         use Pod::To::[module] to render inline documentation

                     when running without "-e" or filename arguments,
                     a REPL is started. By default, if STDIN is a TTY,
                     "interactive" REPL is started that shows extra messages and
                     prompts, otherwise a "non-interactive" mode is used where
                     STDIN is read entirely and evaluated as if it were a program,
                     without any extra output (in fact, no REPL machinery is even
                     loaded). This option allows to bypass TTY detection and
                     force one of the REPL modes.

Note that only boolean single-letter options may be bundled.

To modify the include path, you can set the PERL6LIB environment variable:

PERL6LIB="lib" perl6

The include path will be searched recursively for any modules when Rakudo is started. Directories that start with a dot are ignored and symlinks are followed.

The supported values for --target are:

Target   | Backend | Description
parse    |  all    |  a representation of the parse tree
ast      |  all    |  an abstract syntax tree (before optimizations)
optimize |  all    |  an abstract syntax tree (after optimizations)
mbc      |  MoarVM |  MoarVM byte code
jar      |  JVM    |  JVM archive

For --profile-filename, specifying a name ending in .json will write a raw JSON profile dump. The default if this is omitted is profile-[timestamp].html.

For examples, and notes about correct quoting on Windows, see "Perl 6 One Liners".

Rakudo's behavior can be tweaked by a (growing) number of environment variables; this section attempts to document all those currently in use.

Other variables are listed in Rakudo's github wiki:

User Debugging


Enables verbose information about Perl 6 pod tables. Useful for tweaking table pod for the user's intended output.

Module Loading

RAKUDOLIB, PERL6LIB (Str; src/core/

Appends a comma-delimited list of paths to @INC. RAKUDOLIB is evaluated first.


Causes the module loader to print debugging information to standard error.

Error Message Verbosity and Strictness


Specifies the name of a custom exceptions handler. For example, to load and use Exceptions::JSON class that comes with Rakudo, set this env var to JSON. The exception handling class needs to implement method process that takes a single positional argument: the exception object. If that method returns a truthy value, the exception will also be printed to the terminal, as if the exception handler was not specified.


If true, suppresses deprecation warnings triggered by the is DEPRECATED trait.


If true, deprecation warnings become thrown exceptions.


Displays source code in stack frames surrounded by the specified number of lines of context.


Controls whether .setting files are included in backtraces.

Affecting Precompilation

RAKUDO_PREFIX (Str; src/core/CompUnit/

When this is set, Rakudo will look for the standard repositories (perl, vendor, site) in the specified directory. This is intended as an escape hatch for build-time bootstrapping issues, where Rakudo may be built as an unprivileged user without write access to the runtime paths in NQP's config.

RAKUDO_PRECOMP_DIST (src/core/CompUnit/
RAKUDO_PRECOMP_WITH (src/core/CompUnit/

These are internal variables for passing serialized state to precompilation jobs in child processes. Please do not set them manually.



Specifies what line editor to use. Valid values are Linenoise, Readline, and none, which load Linenoise or Readline line editors, or starts the default (none) line editor that doesn't require any extra modules.


RAKUDO_ERROR_COLOR (Bool; src/core/

Controls whether to emit ANSI codes for error highlighting. Defaults to true if unset, except on Win32.


Override the default maximum number of threads used by a thread pool. Defaults to 16.

RAKUDO_JDB_PORT (Str; src/core/CompUnit/

In perl6-jdb-server for setting the jdb port


RAKUDO_PRECOMP_NESTED_JDB uses perl6-jdb-server with increasing ports for precompilation and RAKUDO_JDB_PORT in perl6-jdb-server is for setting the jdb port.

TMPDIR, TEMP, TMP (Str; src/core/IO/Spec/)

The IO::Spec::Unix.tmpdir method will return $TMPDIR if it points to a directory with full access permissions for the current user, with a fallback default of '/tmp'.

IO::Spec::Cygwin and IO::Spec::Win32 use more Win32-appropriate lists which also include the %TEMP% and %TMP% environment variables.

PATH, Path (Str; src/core/IO/Spec/)

The IO::Spec::Unix.path method splits $PATH as a shell would; i.e. as a colon-separated list. IO::Spec::Cygwin inherits this from IO::Spec::Unix.

IO::Spec::Win32.path will read the first defined of either %PATH% or %Path% as a semicolon-delimited list.

PERL6_TEST_TIMES, (Bool; lib/Test.pm6)

When set to a true value will cause timing information to be printed when the test suite is running:

$ PERL6_TEST_TIMES=1 perl6 -MTest -e 'plan 2; is sleep(2), Nil; nok sleep(.5)'
# between two timestamps 1 microseconds
ok 1 -
# t=2000562
ok 2 -
# t=500388

The # between two timestamps is printed when plan is called and indicates how long it takes just to read the clock to produce a timestamp. # t= values that follow are printed after each test function is executed and the value represents the time in microseconds that elapsed from the previous timestamp (or the # between... message).

Note that if you use done-testing instead of plan, the # between... message will not be displayed and the first # t= value will be a NaN.

PERL6_TEST_DIE_ON_FAIL, (Bool; lib/Test.pm6)

When set to a true value will cause the test suite to abort on first failure, even if there are more tests to be run:

$ PERL6_TEST_DIE_ON_FAIL=1 perl6 t/test-filename.t
RAKUDO_OPTIMIZER_DEBUG, (Bool; src/Perl6/Optimizer.nqp)

When set to a true value, causes to produce extra debugging output, useful for debugging Rakudo's static optimizer.


Set to enable scheduler debugging.


Default number of bytes or chars read by .readchars and .Supply methods in IO::Handle and IO::CatHandle. Defaults to 65536 or the value of RAKUDO_DEFAULT_READ_ELEMS environmental variable, if set.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.