Skip to content
sandbox-workers
Esc
navigateopen⌘Jpreview
On this page

Ruby

Execute code with CRuby 4.0.0 inside a dedicated Wasm Worker.

Package: @sandbox-workers/ruby. Code is a script: the value of the last expression is the result. Supports Enumerable and the bundled standard library. The JavaScript bridge is disabled. gem installation and arbitrary native extensions are unavailable.

Ruby is stateless-only — its runtime Worker always answers contexts: false, so it works in stateless mode only; see Code contexts for why.

Deploy

Deploy to Cloudflare

Or, after npm publication:

pnpm dlx @sandbox-workers/cli init ruby my-sandbox

See deployment setup and Service Bindings. The template requires a Paid plan and creates no public URL.

Example

Env vars:

{ "NAME": "world" }

Code:

name = ENV.fetch("NAME", "world")
puts "Hello from Ruby!"
{message: "Hello, #{name}!", squares: (0..5).map { |x| x*x }}

Every request gets a fresh engine instance. State does not persist between executions. Consult limits for fuel, memory, and output budgets.

License notice

Before use or redistribution, review this runtime’s LICENSE and THIRD_PARTY_NOTICES.md. Bundled interpreters retain their upstream licenses. The package includes the applicable notices in its licenses/ directory.