Write a runtime configuration
Configure a lema.runtime-linux/v2 JSON file for isolated checker output directories, Linux or macOS profiles, or VM-only deployment hosts.
For everyday development, lema setup installs the host’s pinned Lean distribution, creates a default runtime configuration at ~/.lema/runtime.json if needed, installs the matching library pack and checks the sandbox (Set up a machine for Lema). Every lema command resolves its runtime configuration in the following precedence order:
- An explicit
--runtime CONFIGflag on the command line. - The
LEMA_RUNTIMEenvironment variable. - The default
~/.lema/runtime.json.
Follow this guide when you need an isolated output directory, a different supervision profile on Linux, or a VM-only runtime on a deployment host that has no Lean installation. Apple Silicon macOS uses the same schema name, lema.runtime-linux/v2, with "profile": "macos".
Before you start
- For a checking runtime (one that runs Lean elaboration and kernel replay): a verified Lean 4.34.1 distribution directory (
$DIST, verified bylema verify-distribution). - For a VM-only runtime (one that only builds and runs
LemaIRon the Lema VM): no Lean distribution is needed. - Every path named in a runtime configuration must be a canonical absolute path without
.or..segments, owned by the operator user and not writable by group or others.
1. Prepare the protected output directory and shared lock
Create an owner-only (mode 0700) output directory and ensure the machine-wide shared lock file exists with mode 0644 (or 0600):
OUT=$HOME/.lema/runs/run-1
install -d -m 700 "$HOME/.lema" "$HOME/.lema/runs" "$OUT"
touch "$HOME/.lema/native.lock"
chmod 644 "$HOME/.lema/native.lock"What lives inside each path:
output($OUT): Holds the append-only native call ledger (ledger.jsonl), per-call reservation and result records (<name>-reserved.json,<name>-result.json), standard output/error logs (<name>.log), sandbox work directories (work/), the incremental.oleanmodule cache (modules/), compiled VM artifacts (artifacts/), and any output-specificHALTEDfault latch.shared_lock(~/.lema/native.lock): Coordinates sandboxed native calls across the machine. Calls wait up to 600 seconds for an available lock slot. Point all runtime configurations on the same host at the sameshared_lockpath.
2. Write a checking runtime configuration (lema.runtime-linux/v2)
Write the JSON configuration file outside $OUT and outside $DIST (JSON does not expand ~ or $HOME, so always expand variables to full absolute paths). On Apple Silicon macOS:
{
"schema": "lema.runtime-linux/v2",
"distribution": "/Users/you/.lema/toolchains/lean-4.34.1-darwin-aarch64",
"output": "/Users/you/.lema/runs/run-1",
"shared_lock": "/Users/you/.lema/native.lock",
"profile": "macos"
}On Linux x86_64 with a working systemd user manager:
{
"schema": "lema.runtime-linux/v2",
"distribution": "/home/you/.lema/toolchains/lean-4.34.1-linux-x86_64",
"output": "/home/you/.lema/runs/run-1",
"shared_lock": "/home/you/.lema/native.lock",
"profile": "systemd-scope"
}The profile must match the host (Runtime configuration reference):
- Linux defaults to
"systemd-scope", which wraps eachbubblewrapsandbox inside a transientsystemd-run --userscope withMemoryMax=4G,MemorySwapMax=0, and delegatedcpu,memory, andpidscgroup v2 controllers. Use"container"where systemd user scopes are unavailable and container supervision is configured. - Apple Silicon macOS requires
"macos", which confines calls with Seatbelt through/usr/bin/sandbox-execand supervises their process group with a watchdog. CPU/process limits are enforced by the kernel; physical memory and thread counts are sampled, so brief overshoot is possible. The profile does not enforce a swap bound or a hard thread cap.
pins and call_budget are not supported configuration fields. Resource limits and trusted toolchain pins come from the build; the runtime refuses unknown JSON fields.
3. Probe the checking configuration (lema check-runtime)
Before starting a server with a new configuration, probe it with lema check-runtime:
lema check-runtime --runtime "$HOME/.lema/runs/run-1.json"this machine can run the trusted runtimelema check-runtime probes the configured sandbox with a small Lean theorem (1 + 1 = 2) and records the call in that configuration’s output directory. When lema setup runs this probe, it creates a separate output under ~/.lema/checks/. A busy host or lock exits with code 75; fix a refused prerequisite before continuing. The Linux systemd-scope profile has a memory admission floor of 6 GiB plus headroom for other calls. The container and macOS profiles record available memory without that floor.
Do not edit a runtime configuration file while lema serve is running: before every native call, the server re-hashes the configuration file on disk against the digest loaded at startup and refuses with runtime configuration changed if the file was modified.
4. Write a VM-only runtime configuration for deployment hosts
On a deployment host that has the required accepted store objects and only needs to build LemaIR and run VM applications (Release an application), omit the distribution field. This example is for a Linux container host:
{
"schema": "lema.runtime-linux/v2",
"output": "/srv/lema/output",
"shared_lock": "/srv/lema/native.lock",
"profile": "container"
}On Apple Silicon, use "profile": "macos" and paths on that Mac. Build the worker and release for the deployment host’s target.
When you run lema check-runtime --runtime /srv/lema/runtime-vm.json, it verifies the directory permissions and prints:
vm-only: Lean calls refusedA VM-only configuration makes zero Lean calls, binds no Lean toolchain into any sandbox, and refuses any request that would invoke Lean (publish, elaborate, submit, checkpoint import, reverify) before reserving the ledger, while allowing lema build, lema release, and lema run --release.
Common refusals
| Refusal message contains | Cause and fix |
|---|---|
runtime path must be absolute: ... | A path in the JSON file is relative or starts with ~. Replace it with a full path starting with /. |
... and ... overlap | output and distribution share a directory subtree, or shared_lock / the config file sits inside output. Keep them in separate directories. |
runtime path is writable by another user: ... | output, distribution, shared_lock, or a parent directory is group- or world-writable (chmod go-w), or owned by another UID. |
disk reserve (output) | Less than 4 GiB of free disk space remains on the filesystem holding output or shared_lock. |
host executable/library drift: ... | A host binary or shared library changed after the runtime loaded. Restart the server after a legitimate host update. lema pins-report separately reports differences from historical reviewed host pins. |
a native scope is still present | Another lema-native-*.scope unit is active on the host; see Recover from a HALTED latch. |
runtime profile does not match this host | Use macos on Apple Silicon, or systemd-scope / container on Linux x86_64. |
Lema v0.3.2 · Updated 29 October 2026 · Version and compatibility