Skip to content
Run rust source files directly
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

run_rust, a simple utility to execute a rust source file directly

run_rust makes it just a little bit easier to use rust for scripting. Simply call it on a rust source file that has a main function and have it execute.


You can install this program simply by cloning the repository and installing it using cargo.


Supports passing arguments to the script as well as choosing the rustc executable to use.

Use the --help option to explore the available flags and arguments.

run_rust 0.1.0
Justus Adam <>
Run rust source files directly

    run_rust [OPTIONS] <SOURCE_FILE> [-- <SCRIPT_ARGS>...]

    -h, --help       Prints help information
    -V, --version    Prints version information

        --compiler <COMPILER>    Path to the rustc executable to use for compilation

    <SOURCE_FILE>       Source file to run
    <SCRIPT_ARGS>...    Additional arguments to pass to the script


You can use this also to make rust sources themselves executable. Add #!/usr/bin/env run_rust as first line in your script. Or, if you know the exact installation location #!/exact/path/to/run_rust will also work.

How it works

Its actually a rather naive program which does nothing more than compile your source code to a temporary directory and execute it.


It currently only supports using the standard library, and no additional crates and libraries.


This utility exists because I wanted to use rust for scripting. The standard library is rather good, reminiscent of python in my opinion, but unlike python there is a compiler that catches all the horrible mistakes I make all the time. However running rust code as a script always requires to compile an actual binary file, which is clutter to me and also takes up space.

You can’t perform that action at this time.