Packaged Utilities

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

Tip: Domain-specific tools

It is possible to turn these tools into Domain-Specific Tools.

ToolRequired feature(s)Description
rhai-runruns Rhai script files
rhai-replrustylinea simple REPL tool
rhai-dbgdebuggingthe Rhai Debugger

Tip: bin-features

Some bin tools require certain features and will not be built by default without those features set.

For convenience, a feature named bin-features is available which is a combination of the following:

decimalsupport for decimal numbers
metadataaccess functions metadata
serdeexport functions metadata to JSON
debuggingrequired by rhai-dbg
rustylinerequired by rhai-repl

Install Tools

To install all these tools (with full features), use the following command:

cargo install --path . --bins  --features bin-features

or specifically:

cargo install --path . --bin sample_app_to_run  --features bin-features

Run a Tool from Cargo

Tools can also be run with the following cargo command:

cargo run --features bin-features --bin sample_app_to_run

Tools List

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 as Rhai scripts 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 as Rhai scripts.


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

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

rhai-dbg – The Rhai Debugger

Use rhai-dbg to debug a Rhai script.

Filename passed to it will be loaded as a Rhai script for debugging.


The following command debugs the script my_script.rhai.

rhai-dbg my_script.rhai