Ruby runtime via [RVM](https://rvm.io) for [Freestyle](https://freestyle.sh) VMs.
npm install @freestyle-sh/with-rubyRuby runtime via RVM for Freestyle VMs.
``bash`
npm install @freestyle-sh/with-ruby freestyle-sandboxes
`typescript
import { freestyle } from "freestyle-sandboxes";
import { VmRuby } from "@freestyle-sh/with-ruby";
const { vm } = await freestyle.vms.create({
with: {
ruby: new VmRuby(),
},
});
const res = await vm.ruby.runCode({
code: "require 'json'; puts JSON.generate({ hello: 'world' })"
});
console.log(res);
// { result: { hello: 'world' }, stdout: '{"hello":"world"}\n', statusCode: 0 }
`
`typescript`
new VmRuby({
version: "3.3.6", // Optional: specific Ruby version (default: "3.4.8")
})
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| version | string | "3.4.8" | Ruby version to install via RVM. |
Executes Ruby code in the RVM-managed Ruby runtime.
Returns: Promise
`typescript`
type RunCodeResponse
result: Result; // Parsed JSON from stdout (if valid JSON)
stdout?: string; // Raw stdout output
stderr?: string; // Raw stderr output
statusCode?: number; // Exit code
};
Installs gems via gem install or bundle install.
Returns: Promise
`typescript
// Install specific gems
await vm.ruby.install({ deps: ["nokogiri", "colorize"] });
// Install from Gemfile (bundle install)
await vm.ruby.install();
await vm.ruby.install({ directory: "/app" });
`
`typescript
type InstallOptions =
| { deps: string[] }
| { directory?: string; deps?: undefined };
type InstallResult = {
success: boolean;
stdout?: string;
stderr?: string;
};
``
- Freestyle Documentation
- Ruby Documentation
- RVM Documentation