DEVELOPMENT.md
This guide covers everything you need to build, test, and release microsandbox from source.
For contribution guidelines (forking, commit signing, pull requests), see CONTRIBUTING.md.
just, git, and pre-commit
sudo apt install just git and pip install pre-commit (or sudo apt install pre-commit)brew install just git pre-commitjust, Visual Studio Build Tools with MSVC, and Windows SDK; install pre-commit with pip install pre-commit if you want just setup to install Git hooksagentd binary from non-Linux hosts and for building the libkrunfw kernel bundle when it has not already been generated. On Windows, Docker Desktop with Linux containers is preferred when available; Windows Server can use Ubuntu WSL instead.just setup if missing, or install via rustupClone the repository and run the one-time setup:
git clone https://github.com/microsandbox/microsandbox.git
cd microsandbox
just setup
just setup does the following:
vendor/libkrunfw, etc.)agentd and libkrunfw)msb CLI~/.microsandbox/bin/ and libraries to ~/.microsandbox/lib/ on Unix, or %USERPROFILE%\.microsandbox\{bin,lib}\ on Windowspre-commit is availableDuring the build, kernel config prompts may appear — press Enter to accept defaults.
On Linux and macOS, add these to your shell profile (e.g. ~/.bashrc, ~/.zshrc):
export PATH="$HOME/.microsandbox/bin:$PATH"
On Windows, just install places %USERPROFILE%\.microsandbox\bin first in the persistent user PATH; open a new PowerShell, Command Prompt, or Windows Terminal tab before running msb from a fresh shell. Already-open shells keep their old process-local PATH.
Verify the installation:
msb --version
The core development cycle is:
just build && just install
This rebuilds the msb CLI (and ensures agentd and libkrunfw are up to date) then installs the updated binaries to ~/.microsandbox/ on Unix or %USERPROFILE%\.microsandbox\ on Windows.
On Windows, just build-msb targets the native MSVC Rust target (aarch64-pc-windows-msvc on Windows ARM64 or x86_64-pc-windows-msvc on Windows x64). just build-agentd and just build-libkrunfw use a Linux build backend for the guest/kernel artifacts, then link/install Windows-native outputs. The backend is selected with MSB_WINDOWS_LINUX_BUILD_BACKEND=auto|docker|wsl and defaults to auto, which prefers Docker Linux containers and falls back to Ubuntu WSL. Set MSB_WSL_DISTRO=<name> when your WSL distro is not named Ubuntu. Set MSB_WINDOWS_TARGET_ARCH=arm64 or MSB_WINDOWS_TARGET_ARCH=amd64 before running just build-msb if you need to override native target detection.
For Windows Server development, use Ubuntu WSL as the Linux build backend:
$env:MSB_WINDOWS_LINUX_BUILD_BACKEND = "wsl"
wsl --install -d Ubuntu
wsl -d Ubuntu -- bash -lc "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y"
wsl -d Ubuntu -- bash -lc "sudo apt update && sudo apt install -y build-essential musl-tools flex bison libelf-dev libssl-dev bc python3 python3-pyelftools curl xz-utils patch"
For a release-optimized build:
just build release && just install
| Command | Description |
|---|---|
just build | Build everything (agentd + libkrunfw + msb) in debug mode |
just build release | Build everything in release mode |
just build-msb | Build only the msb CLI (debug) |
just build-msb release | Build only the msb CLI (release) |
just build-deps | Build only binary dependencies (agentd + libkrunfw) |
just build-agentd | Build only the Linux guest agentd binary; Windows uses Docker Linux containers or WSL |
just build-libkrunfw | Build only libkrunfw; Windows builds kernel.c through Docker Linux containers or WSL and links libkrunfw.dll natively |
just install | Install msb + libkrunfw to ~/.microsandbox/ on Unix or %USERPROFILE%\.microsandbox\ on Windows |
just uninstall | Remove installed binaries |
just clean | Remove build/ artifacts and clean libkrunfw |
The project is a Cargo workspace with these crates (in dependency order):
| Crate | Path | Description |
|---|---|---|
microsandbox-utils | crates/utils | Shared utilities |
microsandbox-protocol | crates/protocol | Wire protocol definitions (versioning) |
microsandbox-db | crates/db | Database layer |
microsandbox-migration | crates/migration | Database migrations |
microsandbox-image | crates/image | OCI image handling |
microsandbox-filesystem | crates/filesystem | Filesystem composition |
microsandbox-network | crates/network | smoltcp-based networking |
microsandbox-runtime | crates/runtime | VM runtime (libkrun integration) |
microsandbox | sdk/rust | Public SDK crate |
microsandbox-cli | crates/cli | msb CLI binary |
agentd | crates/agentd | In-guest agent (workspace member, built separately for musl) |
| Package | Path | Description |
|---|---|---|
microsandbox (npm) | sdk/node-ts | TypeScript/Node.js SDK (NAPI bindings) |
microsandbox-mcp (npm) | mcp/ | MCP server for AI agents |
vendor/libkrunfw — Submodule for the kernel firmware librarybuild/ — Build output (agentd binary, libkrunfw shared library, msb binary)examples/rust/ — Rust example projectsexamples/typescript/ — TypeScript example projectsRun all workspace tests:
cargo test --workspace
Run tests for a specific crate:
cargo test -p microsandbox-runtime
Run a specific test:
cargo test -p microsandbox test_name
just bench-fs
Runs Docker-vs-Microsandbox filesystem benchmarks (14 workloads covering metadata, reads,
writes, deletes, renames, mmap, and concurrent I/O). Results are written as JSON to
build/bench/fs/. See benchmarks/README.md for full usage,
workload descriptions, multi-image runs, and baseline comparison.
Pre-commit hooks are installed by just setup. They run automatically on every commit and check:
cargo fmt --all --check — formattingcargo clippy --workspace -- -D warnings — lintscargo doc — documentation builds without warningscargo build -p microsandbox-cli — CLI compilesmainTo run all checks manually:
pre-commit run --all-files
It is recommended to run this once before your first commit.
If pre-commit is not installed, install it with pip install pre-commit (or brew install pre-commit on macOS) and then run pre-commit install.
cargo fmt --all # Format code
cargo clippy --workspace # Run lints
Microsandbox releases are automated via CI. The process has two steps:
Create a PR that bumps the version across all crates and packages. All crates and packages share the same version number:
Cargo.toml (workspace version field — all crates inherit from this)sdk/node-ts/package.jsonmcp/package.jsonThe PR title should follow the format: chore: bump version to X.Y.Z
After the version bump PR is merged, create a signed tag on main to trigger the release CI:
git tag -a v0.X.Y -m "v0.X.Y"
git push origin v0.X.Y
The release workflow (.github/workflows/release.yml) will:
msb, agentd, and libkrunfw for release platforms (linux-x86_64, linux-aarch64, darwin-aarch64, windows-x86_64, windows-aarch64).tar.gz) and Windows platform bundles (.zip) with SHA256 checksumsinstall.sh and install.ps1)microsandbox + platform packages)microsandbox-mcp)