lev docs

Install

Terminal
cargo install --git https://github.com/Robertboy18/lev --locked lev-cli
lev --version
lev --help

The Cargo package is lev-cli and the executable is lev. Install Rust first if cargo is missing. lev runs Lean and Lake through elan, so elan has to be on PATH. lev check also needs bwrap (bubblewrap) on Linux unless you pass --no-sandbox.

Check the machine

In the project
lev doctor
lev doctor --json

lev doctor finds the nearest directory with a lean-toolchain file and reports elan, Lean and Lake for that toolchain, Git, bwrap, the kernel binaries the toolchain ships (leanchecker, leanchecker-paranoid, lean4lean, nanoda_bin), whether lev check has built its exporter and reference for the toolchain yet, where Lake's artifact cache lives, and lev's cache directory. Problems come last. It always exits 0.

Lake hard-links cached artifacts only within one filesystem and silently copies them otherwise. When the Lake cache sits on another filesystem than the project, doctor says so; point LAKE_CACHE_DIR at the project's filesystem to share artifacts again.

Explain a rebuild

In the project
lev inspect build
lev inspect build --why Mathlib.Order.Basic -- Mathlib

lev reads every module trace, runs lake --verbose build with Lake's output passing through on stderr, reads the traces again and prints which modules changed and why. Arguments after -- go to lake build, and the exit status is Lake's. Inspection explains the report.

Check a project

In the project
lev check
lev check --kernel official --kernel nanoda --jobs 8
lev check --no-build --json

The first lev check with a toolchain builds lev-export with that toolchain (a few seconds) and exports the toolchain's own Init as the reference (a few seconds more). Both are cached. Every run then builds the project with lake build, exports all modules, and checks one slice per module, reusing every verdict whose slice did not change. It exits 0 when the development is accepted, 1 when it is rejected, and 2 when it could not be checked, including when a kernel run timed out. Checking covers what a slice is and what an accept means.

Look at the caches

Anywhere
lev cache status
lev cache gc
lev cache gc --lake --max-age-days 7 --apply

lev inspect build and lev check register their project. lev cache status inventories lev's cache, the check caches and the Lake caches registered projects used. lev cache gc lists what it would remove and deletes nothing without --apply. It touches Lake's caches only with --lake. Cache says what protects an entry.