Ruvy aims to initialize the ruby VM using wizer and execute ruby code passed into the wasm.
- rustup
- Rust v1.66 (
rustup install 1.60 && rustup override set 1.66
) - wasm32-wasi, can be installed via
rustup target add wasm32-wasi
- cmake, depending on your operating system and architecture, it might not be
installed by default. On Mac it can be installed with
homebrew
viabrew install cmake
- Rosetta 2 if running MacOS on Apple Silicon, can be installed via
softwareupdate --install-rosetta
- Install the
wasi-sdk
by runningmake download-wasi-sdk
- Wizer v3.0.0 (
cargo install wizer --all-features --version 3.0.0
)
- wasmtime-cli, can be installed via
cargo install wasmtime-cli
(required forcargo-wasi
) - cargo-wasi, can be installed via
cargo install cargo-wasi
After all the dependencies are installed, run make
The size of your main ruby program is limited by the max allowable limit for environment variables on your operating system. This is because we use a temporary env var to pass in the contents of the ruby program to the Wasm.
A simple ruby program that prints "Hello world" to stdout
$ cargo run --package=cli ruby_examples/hello_world.rb
$ wasmtime index.wasm
Hello world
You can preload files by pointing to a directory of ruby files. At the moment, it just naively loads each file 1 by 1.
$ cargo run --package=cli --preload=prelude/ ruby_examples/use_preludes_and_stdin.rb
$ echo "this is my input" | wasmtime index.wasm
{:discount_input=>"this is my input", :value=>100.0}