Home

Awesome

Ruvy: A Ruby to WebAssembly toolchain

About this repo

Ruvy aims to initialize the ruby VM using wizer and execute ruby code passed into the wasm.

Build

Development

Using a different WASI SDK

The following environment variables allow you to experiment with different WASI SDKs:

Using a different ruby.wasm

Set the RUVY_WASM_SYS_RUBY_PATH environment variable to a path containing an extracted release asset from https://github.com/ruby/ruby.wasm. The directory the environment variable is set to must contain an include and lib directory.

Building

After all the dependencies are installed, run make

Usage

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}

Ideas for contributions

Here are some ideas for welcome contributions!

Compatibility with Shopify Functions

Ruvy is not currently compatible with Shopify Functions. This is due to the size of the Wasm modules produced by Ruvy exceeding the maximum size of Wasm modules supported by Shopify Functions.

Here are some ideas for how to make Ruvy compatible with Shopify Functions:

Misc