ruby.wasm is a collection of WebAssembly ports of the CRuby. It enables running Ruby application on browsers, WASI compatible WebAssembly runtimes, and Edge Computing platforms.
Try ruby.wasm (no installation needed)Try ruby.wasm in TryRuby in your browser.
Quick Example: Ruby on browserCreate and save index.html
page with the following contents:
<html> <script src="https://cdn.jsdelivr.net/npm/@ruby/3.2-wasm-wasi@2.3.0/dist/browser.script.iife.js"></script> <script type="text/ruby"> require "js" puts RUBY_VERSION # => Hello, world! (printed to the browser console) JS.global[:document].write "Hello, world!" </script> </html>Quick Example: How to package your Ruby application as a WASI application
Dependencies: wasi-vfs, wasmtime
# Download a prebuilt Ruby release $ curl -LO https://github.com/ruby/ruby.wasm/releases/latest/download/ruby-3.2-wasm32-unknown-wasi-full.tar.gz $ tar xfz ruby-3.2-wasm32-unknown-wasi-full.tar.gz # Extract ruby binary not to pack itself $ mv 3.2-wasm32-unknown-wasi-full/usr/local/bin/ruby ruby.wasm # Put your app code $ mkdir src $ echo "puts 'Hello'" > src/my_app.rb # Pack the whole directory under /usr and your app dir $ wasi-vfs pack ruby.wasm --mapdir /src::./src --mapdir /usr::./3.2-wasm32-unknown-wasi-full/usr -o my-ruby-app.wasm # Run the packed scripts $ wasmtime my-ruby-app.wasm -- /src/my_app.rb Hellonpm packages (for JavaScript host environments)
See the README.md
of each package for more detail and its usage.
This project distributes prebuilt Ruby binaries in GitHub Releases. A build is a combination of ruby version, profile, and target.
Triple Descriptionwasm32-unknown-wasi
Targeting WASI-compatible environments (e.g. Node.js, browsers with polyfill, wasmtime, and so on) wasm32-unknown-emscripten
Targeting JavaScript environments including Node.js and browsers Profile Description minimal
No standard extension libraries (like json
, yaml
, or stringio
) full
All standard extension libraries *-js
Enabled JS interoperability, only usable with npm package *-debug
With DWARF info and name
section for debugging
The current WASI target build does not yet support Thread
related APIs. Specifically, WASI does not yet have an API for creating and managing threads yet.
Also there is no support for networking. It is one of the goal of WASI to support networking in the future, but it is not yet implemented.
See CONTRIBUTING.md for how to build and test, and how to contribute to this project. Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/ruby.wasm
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4