RunMat Command Line Interface (CLI)
The RunMat CLI is a fast and easy way to run .m files locally, open an interactive REPL, inspect runtime behavior, and work with remote project filesystems.
Install RunMat first if the runmat command is not already on your PATH. See Installation for install options.
To check the version of RunMat, run:
runmat --versionREPL
Run runmat with no command to open the interactive REPL.
runmatYou can also start it explicitly:
runmat repl
runmat repl --verboseThe REPL keeps one session alive, so variables remain available between prompts.
A = magic(3)
sum(A)REPL commands:
| Command | Use |
|---|---|
help | Show REPL help. |
exit, quit | Leave the REPL. |
.info | Show runtime information. |
.stats | Show execution statistics. |
.gc, .gc-info | Show garbage collector statistics. |
.gc-collect | Force a major collection. |
.reset-stats | Reset execution statistics. |
!cmd | Run cmd in the platform shell and print stdout/stderr. |
Shell escapes are local CLI REPL behavior. A line such as !pwd runs pwd through the host shell without submitting it to the RunMat parser. Non-zero shell exits are reported at the prompt and do not close the REPL. .m scripts and other hosts do not treat leading ! as a shell escape.
The REPL also accepts piped input:
printf "1 + 1\n" | runmat repl
printf "!pwd\n1 + 1\n" | runmat replRun
Run a local .m file by passing the path directly:
runmat analysis.mThe explicit form is:
runmat run analysis.mrunmat run also runs .fea study and parametric sweep files:
runmat run studies/bracket_static.fea
runmat run --json studies/bracket_static.feaThe default .fea output is a concise run summary with the run_id, quality status, evidence path, and a fea.results("<run_id>") post-processing hint. Use --json when automation needs structured output.
RunMat also resolves configured project entrypoints. If a project has runmat.toml with an entrypoint named main, this works:
% runmat.toml
[entrypoints.main]
path = "src/main.m"runmat run mainSee Projects for project layout and entrypoint configuration.
For relative source paths, RunMat can infer a missing .m extension:
runmat run src/mainExecution uses the same session pipeline as other hosts: parse, lower, compile, run, emit streams, update workspace, and report structured diagnostics.
Compile
Use runmat compile to produce a standalone executable for the current host:
runmat compile main.m -o main
./mainCompilation uses the same project/package composition, HIR, MIR, static analysis, builtin catalog, and Native IR as normal execution. Functions in the entry file and configured project source roots are compiled with their stable program identities; list stable cross-directory sources under [sources].roots so they are available to static composition. A runtime-only addpath cannot retroactively add source code to an already linked executable.
The default --policy=native-specialized emits target-native code and links the matching RunMat runtime archive embedded in the runmat binary. The result does not require a separate RunMat installation or SDK directory at runtime. --optimization=none|size|speed controls native object optimization; speed is the default. Native-specialized composition selects exact reachable builtin bindings with ordinary archive extraction and platform dead stripping when the runtime capability and canonical reachability/catalog closure permit it. Otherwise it retains runtime builtin discovery. --explain-link and --link-plan-json report the actual choice.
The final host link uses a supported system linker and the native development libraries behind enabled runtime features, such as HDF5. Install those platform dependencies and expose their standard library search paths to the linker; RunMat supplies its own matching execution runtime and does not require a separate RunMat SDK.
Use --policy=closed-world when every runtime target can be proven. RunMat links only the exact reachable catalog-backed builtin bindings, uses ordinary archive extraction and platform dead stripping, and omits parser, compiler, VM, JIT, and object-emission code from the resulting executable. The small HIR/MIR operation schema required to decode and verify Native IR remains part of the runtime. If a call can reach an unknown target, a dynamically extensible builtin, or a builtin without an exact native binding, compilation fails with a specific diagnostic; use native-specialized when that broader runtime discovery is intentional.
The dynamic-runtime and portable policy names reserve distinct product contracts and fail clearly until their complete implementations are available: dynamic-runtime requires an embedded frontend and dynamic source loader, while portable produces a target-independent artifact instead of a host executable. RunMat does not silently approximate one policy with another.
Temporary object, archive, and response-file inputs are private and removed after linking. Use --keep-temps for linker diagnosis, --linker PATH to select an explicit supported system linker driver, and --force to replace an output. Forced replacement preserves the previous executable until the new link succeeds.
Use --explain-link to see the exact program functions, builtins, classes, method boundaries, providers, extensions, and runtime families retained by compilation, together with the direct, finite-dynamic, or unknown reason for each edge. Closed-world explanations also name each retained builtin binding variant and its stable native symbol. Use --link-plan-json PATH to write the same deterministic report for CI or tooling. The JSON includes the program, runtime archive, builtin catalog, target, policy, capability, and reachability identities used by that compilation; --force is required to replace an existing report.
The compiler validates that the embedded runtime matches the current target, native ABI, schema, RunMat version, runtime identity, and builtin catalog before linking. A source build made with ordinary cargo build intentionally lacks that large embedded archive; use the two-phase build helper described in Build System when developing the standalone workflow.
See Native Compilation for entrypoint and source-closure rules, runtime composition policies, link-plan inspection, platform requirements, and failure diagnosis.
Check
Use runmat check before running a .m script or .fea study:
runmat check analysis.m
runmat check --path ./toolbox analysis.m
runmat check -D warnings analysis.m
runmat check --json analysis.m
runmat check studies/bracket_static.fea
runmat check --json studies/bracket_static.feaFor .m files, check runs the same parser, HIR and MIR lowering, static analysis, source lookup, and compile validation used by editor tooling without executing the script. It reports syntax and semantic errors, proven type or shape incompatibilities, and function calls that cannot be resolved from builtins, the file, or the configured project sources. --path DIRECTORY adds an explicit MATLAB lookup root for the check and may be repeated.
Dynamic MATLAB behavior is reported without being rejected by default. For example, a function that is not present in the static source catalog produces a warning, and a call after addpath identifies that path mutation as the reason the final target must be selected and loaded at runtime. This warning describes a supported dynamic execution boundary, not an execution failure; use [sources].roots or --path when the target should participate in static cross-file analysis. Warnings leave the command successful, while errors return a nonzero exit code. Use -D warnings (or -D warning) when CI should also return nonzero for any warning.
The default output is human-readable and includes diagnostic codes, source locations, related causal locations, notes, and help. For .m files, --json emits the stable schema_version: 1 envelope with an explicit outcome (clean, warnings, or failed), per-domain analysis completeness, structured diagnostics with byte and line/column spans, and summary counts. A failed check still emits that JSON payload before returning nonzero.
For .fea files, check loads geometry, resolves selectors, validates the study or sweep, and builds the solve plan without running the solver.
FEA JSON mode returns structured validation and plan payloads for CI and tooling.
Project sources
If main.m calls toolbox/helper.m, add the helper directory to the check:
runmat check --path toolbox main.mA helper beside main.m is discoverable without --path. For a project-wide
setting, configure source roots in runmat.toml:
[package]
name = "check-example"
[sources]
roots = ["toolbox"]Then use runmat check main.m. The CLI checks that entrypoint and its statically
reached source closure; it does not recursively check independent scripts.
Cross-file diagnostics retain each source's location. Verbose and JSON output
identify partial analysis of unknown inputs, recursion or conditional calls.
The check does not execute addpath. A call whose resolution depends on a runtime
path change reports RM-RES0002; configure a source root or use --path to make
the helper available during analysis. JSON reports that coverage as
runtime_dependent.
Reading diagnostics
Diagnostic codes, source locations and help text describe the problem. For
example, a call to an unavailable definitely_missing function reports:
warning[RM-RES0001]: cannot find function `definitely_missing`
--> missing.m:1:9Check the spelling and put the function beside the script or in a configured
source root. This warning exits successfully by default; -D warnings makes it
fail the check.
For A = ones(2, 3); B = ones(4, 2); C = A * B;, the check reports
RM-TYPE-MATMUL: the inner dimensions 3 and 4 differ. Change the matrix dimensions
to match the intended calculation. Syntax errors, such as value = ;, report
RunMat:ParseError with the source location.
Exit status and automation
| Result | Exit status |
|---|---|
| No errors or warnings | 0 |
Warnings, without -D warnings | 0 |
Errors, or warnings with -D warnings | 1 |
Treat any nonzero status as failure; argument and startup failures may use other nonzero values. To save JSON while preserving the command's status:
status=0
runmat check --json -D warnings analysis.m > check.json || status=$?
cat check.json
exit "$status"Keep stderr separate from the JSON. Analysis failures emit the diagnostic report;
startup, argument or file-loading failures may occur before a report is available.
outcome is clean, warnings or failed. A partial analysis domain describes
coverage and does not itself fail the check.
Diagnostics retain source IDs, byte offsets and line/column coordinates, including
related locations in other files. The sources array maps IDs to paths without
embedding file contents. When source text is unavailable, paths and line/column
coordinates are null, while byte offsets and source identity remain available.
analysis_incomplete_sources, call_context_budget_exhausted and
call_context_precision_withheld describe composition and call-analysis limits.
For checks through the public SDK, see JavaScript and browser checks.
Pass Runtime Options
Global options apply to the REPL, local scripts, and most commands.
runmat --no-jit analysis.m
runmat --gc-preset low-latency analysis.m
runmat --plot-headless analysis.mCommon options:
| Option | Use |
|---|---|
--config PATH | Load a specific runmat.toml or runmat.json. |
--color MODE | Control ANSI styling for human output (auto |
--debug | Enable debug logging. |
--log-level LEVEL | Set log verbosity. |
--verbose | Print more execution detail. |
--offline | Resolve packages only from locally available content. |
--locked | Require an existing, current runmat.lock. |
--frozen | Require the lock and prohibit network access or lock mutation. |
--no-jit | Disable native JIT compilation. |
--jit-threshold N | Accepted but does not control native tiering. |
--jit-opt-level LEVEL | Accepted but does not select native compiler optimization. |
--gc-preset PRESET | Select a GC tuning preset. |
--gc-young-size MB | Override young generation size. |
--gc-threads N | Override GC worker count. |
--gc-stats | Collect GC statistics. |
--plot-mode MODE | Select plotting mode (auto |
--plot-headless | Force headless plotting. |
--plot-backend BACKEND | Select plotting backend (auto |
Configuration is resolved from built-in defaults, project files, environment variables, and CLI flags. CLI flags have the highest precedence. See Configuration Reference.
--jit-threshold N and --jit-opt-level LEVEL are parsed and retained as configuration, but do not select compilation triggers or native compiler optimization. Native tiering tracks function and loop activity, profiles of runtime representations, and compilation budgets. Placement separately chooses among eligible implementations. See JIT Compilation Pipeline. Enabling JIT permits native execution but does not force a particular tier or provider route.
JIT and acceleration settings are independent. With --no-jit, the VM can still use supported GPU operations and fusion. Set [runtime.accelerate].enabled = false when measuring execution without acceleration.
Clusters and Remote Jobs
Create a cluster once, join the machines that will execute work, then add
--cluster to your usual run command. On your computer, sign in as an
organization administrator and create the cluster:
runmat login
runmat cluster create --name engineeringOn the machine joining the cluster, sign in with an authorized account or supply
its API key through RUNMAT_API_KEY, then join by name:
runmat login
runmat cluster join engineeringLeave that terminal running to accept work. Back on your computer, confirm the node is active, select a Server project if needed, and run your script from its local project directory:
runmat cluster nodes engineering
runmat project select PROJECT_ID
runmat analysis.m --cluster engineeringRunMat trusts the authenticated Server to identify the execution machine,
verifies its signed run/allocation evidence, and encrypts the workload automatically.
runmat run analysis.m uses the same path. Omit --cluster to run locally.
The command waits for completion. Add --detach to return after submission:
runmat analysis.m --cluster engineering --detach
runmat job show RUN_ID
runmat job attach RUN_ID
runmat job cancel RUN_IDJoin authorizes machine registration with your signed-in account or API key.
Cluster commands use names. --org is optional with a selected or single authorized
organization; interactive commands ask when the choice is ambiguous.
For background services, automation/JSON output, organization selection, cluster-name rules, dependency locking, draining and organization recovery, see Remote Execution. These are separate from the normal create → join → run flow.
For independent endpoint verification, supply --trust-identity FINGERPRINT or
set RUNMAT_TRUST_IDENTITY. Explicit pins remain strict. See the guide's
encryption and trust details.
Packages
Package resolution is available directly and is also applied automatically by run, REPL, check, benchmark, and bytecode workflows:
runmat package resolve
runmat package fetch
runmat package update
runmat package tree
runmat package why DEPENDENCY
runmat package vendor
runmat package cache status
runmat package cache gc
runmat package cache pruneresolve creates or refreshes runmat.lock; fetch fills missing immutable cache content without selecting a newer locked commit; and update is the explicit operation that may advance a branch or tag. tree and why project the same resolved graph used by execution and static analysis. vendor writes project-local dependency copies plus a workspace-root runmat-vendor.json; frozen execution requires and verifies that record for live path dependencies. See Projects for Git syntax, lock modes, browser behavior, cache recovery, and vendoring.
Test Projects
runmat test discovers MATLAB-style script, function, and class tests semantically, selects them without executing test bodies, freezes the package graph and source revision, and runs the resulting immutable plan:
runmat test
runmat test tests/solver --name convergence --tag fast
runmat test --jobs 4 --isolation process --report junit
runmat test --coverage --coverage-format lcov
runmat test --cluster engineering --max-workers 8Runtime and test dependency groups are resolved together before discovery. The default native isolation is a fresh killable process; session and none are explicit weaker modes. Reports, captured output, diagnostics, artifacts, retries, cancellation, and coverage are projections of one deterministic event/result stream. Human, JSON, JUnit, and TAP reports are supported, as are JSON, LCOV, Cobertura, and HTML coverage reports. Exact options and defaults are available from runmat test --help.
--report-dir places requested reports directly in that directory (for example, test-results.json, test-results.xml, and coverage.lcov). A later run may replace only the same requested report filenames; other files are left alone. Run-scoped artifact copies remain in hashed subdirectories for manifest identity and safe per-run cleanup.
The same portable discovery, plan, coordinator, result, and coverage authorities back runtests, browser Web Worker execution, and Desktop. Test snapshots retain the project's [runtime.language].compat policy through discovery and execution, including isolated workers. CLI test workers inherit the resolved JIT, acceleration and foreign-runtime settings. Browser hosts use fresh dedicated Web Workers as their strongest available isolation and preserve selected source and fixture bytes in an immutable worker-local filesystem snapshot.
Process workers receive platform startup variables and any parent variables explicitly selected with --allow-env NAME or [test].environment-allowlist. Set [runtime.foreign.python].executable to pin interpreter selection; use --allow-env PATH when tests intentionally need the parent's command lookup path.
Remote tests use the same coordinator through the general execution scheduler and encrypted execution control/data plane. --cluster overrides [test.cluster].profile, --queue overrides [test.cluster].queue, and --max-workers caps concurrent remote fixture groups. Endpoint identity comes from authenticated Server admission; optional --trust-identity or RUNMAT_TRUST_IDENTITY adds independent pinning. Workload content is encrypted after the signed evidence is verified. The Server receives the coarse metadata needed to coordinate execution, not the plaintext test content or detailed results.
Remote jobs carry an exact compiled program artifact and frozen package identities inside the encrypted execution bundle, without source bytes or a project handoff. Drivers and workers validate the artifact, target, package graph, and source revision identities and execute it without reconstructing a source tree. Remote tests retain the separate source-project closure they need for fixtures, dynamic test discovery, and source-aware reporting; workers validate and materialize those verified logical objects into a private read-only source root. Package resolution and private-package decryption happen only on the submitting client in both cases, so remote workers need no Git, Server-project, registry, or package-decryption credentials and cannot silently select a different dependency.
Color and Terminal Output
RunMat uses restrained ANSI styling for human-readable diagnostics, help, headings, status messages, and summaries. The default --color=auto mode checks stdout and stderr independently, styles only streams connected to capable interactive terminals, and stays plain when output is redirected, TERM=dumb, or a non-empty NO_COLOR value is present.
Use the global color option before or after a subcommand:
runmat --color=never check analysis.m
runmat check analysis.m --color=never
runmat --color=always check analysis.m | less -RAn explicit --color=always or --color=never overrides the environment. Without an explicit option, a non-empty NO_COLOR disables color; CLICOLOR=0 also disables it; and CLICOLOR_FORCE or FORCE_COLOR can request color for eligible human output. NO_COLOR takes precedence over those environment force variables. An empty NO_COLOR value is treated as unset.
Structured and byte-oriented output remains plain even under --color=always. This includes JSON, TOML configuration, bytecode, stable tab-separated remote listings, telemetry payloads, and raw remote file contents. RunMat also leaves MATLAB stdout and stderr, displayed MATLAB values, and REPL shell-command output unchanged.
Emit Bytecode
Use bytecode output when debugging the compiler pipeline or checking what a script lowers into before execution.
runmat --emit-bytecode analysis.mWrite the disassembly to a file:
runmat --emit-bytecode bytecode.txt analysis.mWhen bytecode emission is enabled, the script is compiled and disassembled instead of being executed.
Capture Artifacts
For batch jobs, CI, and notebook-style hosts, the CLI can write a run manifest and exported figure images.
runmat \
--artifacts-dir .runmat-artifacts \
--capture-figures auto \
--figure-size 1280x720 \
analysis.mThe manifest records execution metadata, stream sizes, touched figure handles, figure export paths, JIT usage, and any error identifier. Figure capture writes PNG files under the artifact directory when figures are touched or when capture is forced on.
Artifact options:
| Option | Use |
|---|---|
--artifacts-dir PATH | Directory for run artifacts. |
--artifacts-manifest PATH | Exact JSON manifest path. |
--capture-figures MODE | Figure export policy (off |
--figure-size WIDTHxHEIGHT | Figure export dimensions. |
--max-figures N | Maximum number of touched figures to export. |
Inspect Runtime
Use these commands when filing issues, tuning performance, or checking what runtime configuration is active.
runmat info
runmat version --detailed
runmat gc stats
runmat accel-info| Command | Use |
|---|---|
info | Print version, runtime configuration, environment, and GC status. |
info --json | Emit versioned JSON describing the runtime features compiled into this executable. |
version --detailed | Print build details useful for support and bug reports. |
gc stats | Print current GC counters. |
gc minor, gc major | Force a minor or major collection. |
gc config | Print current GC configuration. |
accel-info | Print acceleration provider and telemetry details. |
accel-info --json | Emit acceleration details as JSON. |
Configuration
Generate a starter config:
runmat config generate -o runmat.tomlInspect resolved configuration:
runmat config show --format toml
runmat config show --format jsonValidate and locate config files:
runmat config validate runmat.toml
runmat config pathsconfig generate writes both project and runtime sections, so the generated file can be used as a starting point for named entrypoints and runtime tuning.
Benchmark
Benchmark a script or named entrypoint with repeated execution in one session.
runmat benchmark analysis.m --iterations 25
runmat benchmark main --iterations 25 --jitThe benchmark command performs warmup runs, then reports total iterations, JIT executions, interpreter executions, total time, average time, and throughput.
Remote Projects
Remote commands connect the CLI to a RunMat server project. They are useful for hosted workspaces, shared project filesystems, and remote data layouts that should be mounted into local execution.
Authenticate first:
runmat login
# or explicitly specify the server URL
runmat login --server https://api.runmat.comFor automation, pass an API token:
runmat login \
--server https://api.runmat.com \
--api-key "$RUNMAT_API_KEY" \
--project <project-id>Alternatively, use environment variables to set the server URL and API token:
| Variable | Use |
|---|---|
RUNMAT_CONFIG | Runtime config path. |
RUNMAT_SERVER_URL | Remote server URL. |
RUNMAT_API_KEY | Remote API token. |
RUNMAT_ORG_ID | Default remote org. |
RUNMAT_PROJECT_ID | Default remote project. |
List and select projects:
runmat org list
runmat project list
runmat project select <project-id>Use the project filesystem:
runmat project fs ls /data
runmat project fs read /data/input.mat --output input.mat
runmat project fs write /data/input.mat ./input.mat
runmat project fs mkdir /data/results --recursive
runmat project fs rm /data/old.matThe top-level fs command is a shorthand for the project filesystem namespace:
runmat fs ls /dataRun a script loaded from the remote filesystem:
runmat remote run /scripts/analysis.m
runmat remote run /scripts/analysis.m --project <project-id>remote run reads the source from the selected remote project, installs the remote filesystem provider for the run, and executes the script locally with the current runtime configuration.
Remote filesystem commands also cover file history, manifest history, snapshots, retention policy, and git-style project sync. Use command help for the full tree:
runmat project fs --help
runmat project retention --help
runmat fs --helpCommand Help
Every command and subcommand has built-in help.
runmat --help
runmat run --help
runmat config --help
runmat project fs --helpUse command help as the source of truth for exact flags in the installed version.
JavaScript and browser checks
After installing the host filesystem through initRunMat, the public SDK's
checkSource calls the same Rust project frontend as the CLI. No JavaScript
parser or shadow checker runs, and checking does not execute user code.
import { checkSource } from "runmat";
const script = await checkSource({ target: { kind: "script", path: "/project/src/main.m" } });
const fn = await checkSource({
target: { kind: "function", path: "/project/src/helper.m", function: "helper" },
});
const project = await checkSource({ target: { kind: "project", path: "/project/runmat.toml" } });
const diagnostics = project.documents.flatMap(document => document.diagnostics);Script/function checks compose the statically reached source closure. A project
check additionally checks every indexed root-package .m source, including
unreached scripts/functions. Each document has its own source table; never join
source IDs from different document reports. Shared dependency diagnostics can
occur in more than one root report. The compiler's completeness/resolution fields
remain visible; a clean report does not prove runtime-dependent calls safe.
userSettingsJson supplies the optional host-owned user layer; project settings,
including language compatibility, come from the selected project's actual
manifest. policy: "clusterWorker" excludes the user layer. searchPaths uses
the original captured filesystem CWD, as the CLI does. Function selection uses
the actual primary HIR module's top-level function identities, not a filename,
public-callability catalog or name-only match in a companion source. A private
function file or server.m declaring main can be checked directly. Parse and
lowering errors remain their original diagnostics when no HIR is available.
Optional inputManifest uses the existing immutable versioned filesystem
contract. Include the manifest, primary source and any reached sources; missing
versions reject rather than reading live replacements. Otherwise the check uses
the current host filesystem captured at request admission. It retains that
authority across asynchronous reads using a filesystem-owned thread/poll-local
read scope, without mutating the process provider. Selected runtime filesystem
authority takes precedence; a different selected owner is refused, never masked.
Infrastructure/configuration/selection failures reject the
Promise; compiler findings remain structured diagnostics in the returned report.
Diagnostics retain CLI code, severity, category, primary, secondary,
notes/help/suggestions, plus typed producer stage and location/related
aliases. Stages come from compiler operations, never diagnostic message/category
strings. Locations preserve UTF-8 byte start/end and one-based
Unicode-scalar line/column coordinates. They are not zero-based LSP UTF-16
positions. A span with an unknown explicit source ID stays unlocated rather
than borrowing another document's coordinates. Older WASM without checkSource
rejects explicitly and requires matching rebuilt browser assets.