Skip to main content
The Daytona Ruby SDK provides an idiomatic Ruby interface for interacting with Daytona Sandboxes, with clean syntax and integration with the Ruby ecosystem.

Installation

If using Bundler:

Quick Start

Configuration

Using Environment Variables

Set the following environment variables:
Then initialize the client:

Using Configuration Object

Sandbox Management

Creating Sandboxes

Basic Sandbox Creation

Customized Sandbox Creation

Listing Sandboxes

Getting a Sandbox

Sandbox Lifecycle

Setting Labels

Code Execution

Running Ruby Code

Executing Shell Commands

File Operations

Uploading Files

Downloading Files

File System Operations

Git Operations

Cloning Repositories

Git Status and Branches

Committing Changes

Language Server Protocol

Starting an LSP Server

Code Intelligence

Stopping LSP Server

Error Handling

Complete Example

Working with Rails

API Reference

Daytona Class

Methods

  • create(params = {}) - Create a new sandbox
  • get(sandbox_id_or_name) - Get a sandbox by ID or name
  • list(options = {}) - List sandboxes with pagination
  • delete(sandbox) - Delete a sandbox
  • start(sandbox) - Start a stopped sandbox
  • stop(sandbox) - Stop a running sandbox

Sandbox Class

Properties

  • fs - FileSystem operations interface
  • git - Git operations interface
  • process - Process execution interface
  • id - Sandbox ID
  • state - Current state
  • labels - Custom labels (readable and writable)
  • env - Environment variables

Methods

  • get_preview_link(port) - Get port preview URL

Process Class

Methods

  • exec(command:, cwd: nil, timeout: nil) - Execute a shell command
  • code_run(code:, params: nil) - Execute code directly

FileSystem Class

Methods

  • upload_file(content, path) - Upload a file
  • upload_files(files) - Upload multiple files
  • download_file(path) - Download a file
  • download_files(requests) - Download multiple files
  • list_files(path) - List files in a directory
  • create_folder(path, mode: '755') - Create a folder
  • search_files(root, pattern) - Search for files
  • replace_in_files(files, old_str, new_str) - Replace content in files

Git Class

Methods

  • clone(url, path, options = {}) - Clone a repository
    • Options: :branch, :username, :password
  • status(path) - Get repository status
  • branches(path) - List branches
  • add(path, files) - Add files to staging
  • commit(path, message, author, email) - Commit changes
  • push(path, options = {}) - Push changes
    • Options: :username, :password

Best Practices

Always Use Begin-Ensure for Cleanup

Check Exit Codes

Use Symbols for Hash Keys

Use Heredocs for Multi-line Code

Integration Examples

Sinatra Application

Background Job (Sidekiq)

Rake Task

Next Steps

SDK Overview

Compare all available SDKs

API Reference

Complete API documentation

Examples

Browse Ruby examples on GitHub

Python SDK

Learn about the Python SDK