Skip to content

Install the pinned Lean distribution

Install and verify the pinned Lean 4.34.1 toolchain automatically with lema toolchain install, from a pre-staged offline archive, or step by step with lema verify-distribution.

Lema v0.3 pins Lean 4.34.1 separately for Linux x86_64 and Apple Silicon macOS. It uses these distributions instead of a system-wide elan installation, checking the archive’s SHA-256 and the extracted files against the host’s committed manifest. Canonical objects keep their identities across hosts; the executable and module cache belong to the host where they were built.

Before you start

  • Linux x86_64 or Apple Silicon macOS, with lema built from v0.3.0 and on your PATH (Set up a machine for Lema).
  • curl for automatic downloads. The Linux manual extraction example below also uses sha256sum and tar with zstd support; the built-in installer needs neither.

1. Automatic installation (lema toolchain install)

For everyday development, use lema setup: it installs the toolchain, configures the runtime, installs the matching release library pack and probes the sandbox. To install or inspect only the toolchain and default runtime configuration, run:

Shell
lema toolchain install
Output
installed /home/you/.lema/toolchains/lean-4.34.1-linux-x86_64 (17738 files, 12 symlinks; manifest c82b7b44dd02…)
wrote /home/you/.lema/runtime.json

The output above is from Linux. On Apple Silicon, the installation directory is ~/.lema/toolchains/lean-4.34.1-darwin-aarch64 and a new configuration uses "profile": "macos". The Darwin manifest covers 17,711 regular files and no symlinks. The schema stays lema.runtime-linux/v2 on both hosts.

lema toolchain install reuses an existing installation that passes verification, without downloading the archive again. It preserves an existing runtime configuration. See Requirements for both hosts’ archive, manifest and Lean executable pins.

2. Offline or custom-directory installation (--dir and --archive)

When you have downloaded the archive separately and want a custom directory, pass --dir and --archive. For example, on Apple Silicon macOS:

Shell
lema toolchain install \
  --dir "$HOME/.lema/toolchains/lean-4.34.1-darwin-aarch64" \
  --archive "$HOME/Downloads/lean-4.34.1-darwin_aarch64.tar.zst"

On Linux x86_64:

Shell
lema toolchain install \
  --dir /opt/lema/lean-4.34.1 \
  --archive /var/cache/lema/lean-4.34.1-linux.tar.zst

The installer checks the archive against the current host’s committed SHA-256 pin, refuses any entry that attempts to traverse outside --dir, writes extraction-manifest.json, marks the extracted tree read-only (a-w), and checks its entire file set. A Linux archive cannot substitute for the Darwin archive.

3. Manual extraction on Linux x86_64

This example uses the Linux archive, manifest and command-line tools. On Apple Silicon, use the automatic or offline installer above, which selects the Darwin pins for you. To extract the Linux distribution by hand from a v0.3.0 lema-lang checkout:

  1. Create the destination directory and ensure neither it nor its parent directories are writable by group or others (go-w):
    Shell
    DIST=$HOME/.lema/toolchains/lean-4.34.1-linux-x86_64
    mkdir -p "$HOME/.lema/toolchains"
    chmod go-w "$HOME/.lema" "$HOME/.lema/toolchains"
  2. Download the official Lean 4.34.1 Linux archive:
    Shell
    curl -fLO https://github.com/leanprover/lean4/releases/download/v4.34.1/lean-4.34.1-linux.tar.zst
  3. Verify the downloaded archive’s SHA-256 against ARCHIVE_SHA in crates/lema-check/src/pins.rs:
    Shell
    echo "47bf4bbd78f70c2e9670598ab7124d92b6efb7330ff33e5fbb4030f6fd72e4e4  lean-4.34.1-linux.tar.zst" | sha256sum -c -
  4. Extract the archive into $DIST (always pass --no-same-owner if running as root so extracted files are owned by root rather than the numeric UIDs recorded in the tar archive):
    Shell
    mkdir -p "$DIST"
    tar --zstd --no-same-owner -xf lean-4.34.1-linux.tar.zst -C "$DIST"
  5. Copy the committed extraction manifest into $DIST/extraction-manifest.json and make the entire tree read-only:
    Shell
    cp toolchain/lean-4.34.1-linux.extraction-manifest.json "$DIST/extraction-manifest.json"
    chmod -R a-w "$DIST"
  6. Verify the extracted tree with lema verify-distribution and probe the sandboxed runtime:
    Shell
    lema verify-distribution "$DIST"
    lema check-runtime

Troubleshooting verification refusals

Refusal message containsCause and fix
.../extraction-manifest.json: No such file or directoryextraction-manifest.json was not copied into the root of $DIST (Step 5), or $DIST points one directory level too deep.
distribution manifest driftextraction-manifest.json does not match the current host’s committed DISTRIBUTION_SHA. Use that host’s archive and manifest.
runtime path is writable by another user: ...A file or directory inside $DIST is writable or owned by another user. Run chmod -R a-w "$DIST".
runtime parent is writable by another user: ...A parent directory of $DIST is group- or world-writable without the sticky bit. Run chmod go-w on the parent directories.
runtime path is a symlink: ...$DIST itself is a symlink. Pass the canonical directory path instead.
distribution file set drift or distribution file drift: ...Extra, missing, or modified files were found inside $DIST. To wipe $DIST and reinstall cleanly, restore write permissions first: chmod -R u+w "$DIST" && rm -rf "$DIST", then run lema toolchain install.

Lema v0.3.2 · Updated 29 October 2026 · Version and compatibility