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
~/.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.How runtime selection works
The SDK checks these locations in order:- Explicit paths: environment variables, process-level setters, then configured paths.
- Runtime home: configured
home, thenMSB_HOME, then~/.microsandbox. - SDK package: bundled binaries, when available.
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=optionalalso removes the required addon. - Rust: embedding is opt-in. To also disable the default Cargo-time runtime download:
setup::ensure_runtime() explicitly with these features.
Use a custom kernel
If your workload needs additional Linux kernel features, build a customlibkrunfw, 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.- Enable the required kernel options or apply your patches, then follow the build instructions for your platform and architecture.
- Select the compatible
msbexecutable and your rebuilt library before starting your application.
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 theembedded_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
Customize installation
Customize installation
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.
Override runtime paths
Override runtime paths
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.Read a runtime version
Read a runtime version
TypeScript and Rust can read the Cargo package version embedded in an Rust returns
msb executable without running it. This is an optional inspection of the specified file; firmware and a complete runtime installation are not required.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.Inspect Go versions
Inspect Go versions
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.Compatibility: setup APIs before v0.7
Compatibility: setup APIs before v0.7
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/Setupbuilder with runtime helpers acceptingRuntimeConfigandInstallOptions. - Go: replace
SetupOptionwithRuntimeConfigandInstallOptions. ReplaceWithSkipDownloadwithResolveRuntimewhen installation must be avoided.