Need help with ruby-wasm?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

235 Stars 18 Forks MIT License 5 Commits 6 Opened issues


A Ruby gem to quickly get started with WebAssembly

Services available


Need anything else?

Contributors list

# 97,125
4 commits
# 33,248
1 commit

Ruby on WebAssembly

Welcome! 👋

This is the repo for the

gem and also a place to start a conversation about Ruby and WebAssembly, and how our community might leverage this new capability. For some background, check out my blog post on the subject. This is largely an experiment at the moment — there are plenty of things this gem doesn't do, but it's a starting point and will hopefully get you up and running quickly so we can learn and explore together.

Feel free to open an issue about anything at all, even just to chat. Enjoy!

Building the gem and dependencies


to build this gem and install locally.


rake mruby_latest
to set the MRuby submodule to the latest release and
rake mruby_master
to switch to the master branch.


rake build_mruby
to build an MRuby static library for WebAssembly, which will be placed in the
directory (a prebuilt one is already there).

When a new version of MRuby is released, update the version number in the

, run
rake mruby_latest
, and
rake build_mruby

Using the gem

Get it with

gem install wasm

Once installed, you'll have access to the

command-line utility. Use this utility to build and serve Ruby apps for WebAssembly. Running it without any options will print its usage. Troubleshoot your WebAssembly toolchain with
ruby-wasm doctor

What this gem currently does: - Compile a single Ruby script to a binary


What it doesn't do yet (maybe something you'd like to work on 🤔): - Build several scripts at a time, or pull in others via

- Allow you to call JavaScript from Ruby, or vice versa - Use any arbitrary Ruby gem; we're using MRuby here, so you can use mrbgems (see list) - Fetch and interpret a Ruby script on page load

A quick example

First, make sure you have the WebAssembly toolchain installed and activated — see the "Getting Started" guide for details.

Start by cloning this repo (the

option also grabs the MRuby submodule and initializes it):
git clone --recursive

into the directory. Notice there's a file called
— we're going to build it for WebAssembly!

Make sure you have this

gem installed. Remember, you can check for issues using
ruby-wasm doctor

Now, we'll build (or compile) the "Hello Ruby!" app using:

ruby-wasm build hello.rb

This will create a

directory and generate the following files: -
— Our compiled Ruby app in binary WebAssembly format -
— JavaScript needed to fetch our
binary and initialize the WebAssembly environment (learn more) -
— A simple HTML template with a
 tag to load the JavaScript file above

To view our Ruby WebAssembly app in the browser, we'll have to serve the files over HTTP (the JavaScript above will use the Fetch API to load the

binary). Run
ruby-wasm serve
to do this.

Finally, open your favorite web browser and go to

. Open your web inspector / developer tools and you'll see "Hello Ruby!" printed in the console. Exciting! 🙌

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.