Packaged Utilities

A number of Rhai-driven tools can be found in the src/bin directory:

rhai-repla simple REPL, interactively evaluate statements from stdin
rhai-runruns each filename passed to it as a Rhai script

Install Tools

To install these tools (with decimal and metadata support), use the following command:

cargo install --path . --bins  --features decimal,metadata

or specifically:

cargo install --path . --bin rhai-run  --features decimal,metadata

rhai-repl – The Rhai REPL Tool

rhai-repl is a particularly useful tool – it allows one to interactively try out Rhai’s language features in a standard REPL (Read-Eval-Print Loop).

Filenames passed to it as command line arguments are run and loaded before the REPL starts.

Test functions

The following test functions are pre-registered, via Engine::register_fn, into rhai-repl. They are intended for testing purposes.

test(x: i64, y: i64)returns a string with both numbers
test(x: &mut i64, y: i64, z: &str)displays the parameters and add y to x


The following command first runs three scripts – init1.rhai, init2.rhai and init3.rhai – loading the functions defined in each script into the global namespace.

Then it enters an REPL, which can call the above functions freely.

rhai-repl init1.rhai init2.rhai init3.rhai

rhai-run – The Rhai Runner

Use rhai-run to run Rhai scripts.

Filenames passed to it as command line arguments are run in sequence.


The following command runs the scripts script1.rhai, script2.rhai and script3.rhai in order.

rhai-run script1.rhai script2.rhai script3.rhai

Running a Tool from Cargo

Tools can also be run with the following cargo command:

cargo run --bin {program_name}