Skip to main content
Local sandboxes need msb and libkrunfw. Call the setup helper once at application startup: it reuses an existing runtime or installs one when missing. Sandbox creation does not download it automatically. Cloud sandboxes do not need a local runtime.

Set up the runtime

The default installation directory is ~/.microsandbox (%USERPROFILE%\.microsandbox on Windows). Keep msb and libkrunfw from the same runtime bundle.

Choose a setup operation

Use ensure for normal startup. The calls below are alternatives; choose the one your application needs.
Ensure does not repair incomplete installations or ignore invalid explicit paths.

How runtime selection works

The SDK checks these locations in order:
  1. Explicit paths: environment variables, process-level setters, then configured paths.
  2. Runtime home: configured home, then MSB_HOME, then ~/.microsandbox.
  3. SDK package: bundled binaries, when available.
A complete home installation wins over bundled Python and Node runtimes, even if its version differs from the SDK. Updating an SDK does not replace that installation. Go also reuses a complete home installation. Managed runtime paths override user choices. To use a custom installation, set both MSB_PATH and MSB_LIBKRUNFW_PATH before constructing a backend. See path overrides for SDK setters and precedence details.

Advanced setup

Bring your own runtime

Install a matching pair with the CLI installer, or provision it yourself and select its paths above.
  • Node: the platform package includes the runtime and native addon. --omit=optional also removes the required addon.
  • Rust: embedding is opt-in. To also disable the default Cargo-time runtime download:
You can still call setup::ensure_runtime() explicitly with these features.

Use a custom kernel

If your workload needs additional Linux kernel features, build a custom libkrunfw, the library that bundles the guest kernel. This applies to local sandboxes; it does not change the managed cloud kernel.
Start from the vendor/libkrunfw revision pinned by your microsandbox release in our libkrunfw fork. It includes the kernel patches microsandbox relies on; an upstream build may not be compatible.
  1. Enable the required kernel options or apply your patches, then follow the build instructions for your platform and architecture.
  2. Select the compatible msb executable and your rebuilt library before starting your application.
For example, on Linux, replace these paths with your executable and custom library:
You can also use the SDK path setters. In Rust, set_sdk_libkrunfw_path() is process-wide, not a SandboxBuilder method; call it before constructing the backend. Boot a fresh guest to use the new kernel. Running guests and full snapshots retain their existing kernel.

Offline installation

Use a directory or archive source to install a pre-downloaded release bundle. To require an installation that already exists, call the resolve helper instead of ensure. See installation examples and options and offline deployment.

Embedded runtime

If your SDK build includes an embedded runtime archive, you can install from it without downloading. Select the embedded_archive source in the installation options. Ensure reuses an existing runtime before extracting the archive. Resolve only finds an existing installation; it does not extract one.

Troubleshooting

For existing installations, see the v0.7 migration guide before upgrading a shared database. Helper details are available below.

API reference

Python, TypeScript, and Go accept a RuntimeConfig and InstallOptions. Their per-call home and binary-path overrides are layered on persisted global configuration. Rust accepts GlobalConfig and InstallOptions directly. Environment binary-path overrides retain the highest priority.Use the directory source to provision a runtime from a flat release-bundle directory containing msb and libkrunfw side by side, without downloading:
An embedded source requires a native SDK built with an embedded runtime archive. If unavailable, explicit installation errors. Ensure still reuses an existing pair before acquisition, even when an embedded source is requested. To require a pre-provisioned runtime, call resolve directly. Each call uses its own configuration; Go no longer caches a process-wide successful setup result.
The TypeScript, Rust, Python, and Ruby SDKs can override process-wide runtime paths directly. Call setters before creating a local sandbox. Automatic package discovery is a fallback and does not occupy the explicit setter slot. A public libkrunfw setter overrides the library for the selected executable, whether that executable comes from configured paths, home, or a package.
Set runtime paths before constructing a backend. Each backend captures these settings; create a new backend to pick up changes. Environment variables work across the SDKs and take precedence over SDK-provided or user-configured paths. Managed runtime paths take precedence over all three:Set these process-wide overrides before creating any local sandbox. Prefer setting MSB_PATH and MSB_LIBKRUNFW_PATH together to select a matching pair. MSB_PATH alone may resolve a library adjacent to that executable; MSB_LIBKRUNFW_PATH alone is incomplete and fails closed. An incomplete explicit pair is not repaired by falling back to another installation. MSB_AGENTD_PATH takes precedence over global paths.agentd; the selected file is read eagerly and must name a compatible Linux ELF executable. These variables do not belong to an individual sandbox configuration.
TypeScript and Rust can read the Cargo package version embedded in an msb executable without running it. This is an optional inspection of the specified file; firmware and a complete runtime installation are not required.
Rust returns Option<setup::Version> and TypeScript returns string | null. Older executables without the version section produce None or null. Invalid executable metadata, malformed version sections and file access failures are errors. The reader supports ELF, PE and thin or universal Mach-O files, limits metadata reads to 4 MiB and version contents to 256 bytes, and never falls back to executing msb --version. Universal Mach-O slices must agree on the version, including section absence. The version identifies the build; it does not authenticate the executable or guarantee feature compatibility.Sandbox startup separately resolves a tested launch contract for the selected runtime. When embedded version metadata is absent, startup may run a bounded msb --version probe and cache the result for that native executable’s identity within the SDK process. Replacing the executable invalidates that cache. This startup behavior does not change the read-only version inspection methods above.
Go setup helpers may load the SDK’s embedded FFI library on first use; resolve does not install host runtime binaries.Go also exposes the SDK’s pinned release version and the version reported by the loaded FFI library:
SDKVersion() string does not load the FFI library. RuntimeVersion() (string, error) loads it automatically on first use and returns an error if loading fails.
These APIs were replaced in v0.7.0. Use this mapping when upgrading from v0.6; new applications should use the current helpers above.
  • TypeScript: replace the setup / Setup builder with runtime helpers accepting RuntimeConfig and InstallOptions.
  • Go: replace SetupOption with RuntimeConfig and InstallOptions. Replace WithSkipDownload with ResolveRuntime when installation must be avoided.
Install and ensure now return the selected runtime paths. Rust’s four helper names and Ruby’s setup API are unchanged. See setup operations.