> ## Documentation Index
> Fetch the complete documentation index at: https://docs.proofpod.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Lean and Mathlib versions

> How ProofPod picks Lean and Mathlib versions, and how to override them.

By default the cloud uses the versions your project uses locally. You can
override either one.

## How versions are chosen

**Lean**, first match wins:

1. `--lean VERSION` on the command line (or `PROOFPOD_LEAN`, or `lean` in
   `proofpod.toml`).
2. elan's prefix on the command itself: `pp lake +v4.35.0 build`.
3. The project's `lean-toolchain` file.
4. Outside a project: the toolchain your local `lean` resolves to.
5. If none of those exist: the service default (`pp envs` shows it).

**Mathlib**, first match wins:

1. `--mathlib REV` (or `PROOFPOD_MATHLIB`, or `mathlib` in `proofpod.toml`).
2. The commit pinned for `mathlib` in the project's `lake-manifest.json`.
3. If there is no manifest yet: the revision named in the lakefile, if any.

`pp status` shows what was detected and where it came from:

```console theme={null}
$ pp status
Service     https://proofpod.dev  signed in
Project     /home/ada/formalization
Lean        v4.36.0  from lean-toolchain
Mathlib     v4.36.0  from lake-manifest.json
Workspace   formalization-3fa9c21b7e
Limits      4 CPU · 16 GiB · timeout 1h00m
```

`VERSION` accepts `4.36.0`, `v4.36.0`, a release candidate such as
`v4.37.0-rc1`, a dated nightly such as `nightly-2026-11-20`, or a full elan
toolchain name such as `leanprover/lean4:v4.36.0`. Moving channels (`nightly`,
`beta`) are rejected because the result would not be reproducible.

`REV` accepts a tag (`v4.36.0`), a branch (`master`) or a full commit hash.

## Environments

An **environment** is a Lean toolchain plus, optionally, a complete Mathlib
checkout with every `.olean` already built. Environments are identified by the
exact toolchain and the exact Mathlib commit, and they are shared: the first
person to need a pair pays the build time, everyone after starts instantly.

```console theme={null}
$ pp envs
LEAN     MATHLIB  COMMIT
v4.36.0  v4.36.0  fc4f59e577fe
v4.36.0  none
```

If your versions are not listed, the first command you run builds the
environment. It takes about five minutes for a Mathlib environment and about a
minute for Lean alone, and it is free:

```console theme={null}
$ pp lake build
proofpod: Preparing Lean v4.35.0 + Mathlib v4.35.0 for the first time. This takes a few minutes and only happens once per version.
```

## How prebuilt Mathlib reaches your project

Lake expects dependencies under `.lake/packages/`. Before your command runs,
ProofPod compares each package pinned in your `lake-manifest.json` with what the
environment has built. Where the commit matches exactly, the package directory
in your cloud workspace becomes a link to the prebuilt copy. Lake then finds a
checkout at the right commit with up-to-date build outputs and has nothing to
fetch or compile.

Mathlib and the packages it depends on (Batteries, Aesop, Qq, ProofWidgets,
Plausible, ImportGraph, LeanSearchClient, Cli) are handled this way. Any other
dependency is cloned and built by Lake into your workspace the first time, then
cached there.

This is why:

* you never need `lake exe cache get` in the cloud (running it is harmless and
  reports there is nothing to download);
* a project that imports all of Mathlib leaves only its own build outputs in
  its workspace, around 19 MB for a small project;
* `pp lake clean` cannot make you rebuild Mathlib.

## When versions disagree

A Mathlib commit is built for exactly one Lean version.

| Situation | What happens |
| - | - |
| Project's Lean matches the Lean its Mathlib is built for | Prebuilt Mathlib is used. The normal case. |
| Project's Lean differs from the Lean its pinned Mathlib is built for | ProofPod tells you, uses your Lean, and Mathlib builds from source, exactly as it would locally. Fix the mismatch with `pp lake update`. |
| `--mathlib REV` given, project's Lean differs | ProofPod uses the Lean that Mathlib `REV` is built for and tells you. |
| `--mathlib REV` and `--lean VERSION` given, and they do not match | The command is refused with an explanation. |
| Mathlib pinned to a commit that is not in `leanprover-community/mathlib4` (a fork) | No prebuilt environment applies; Mathlib builds from source in your workspace. |

## Overriding versions

### Try a project against another Mathlib

```console theme={null}
$ pp --mathlib v4.35.0 lake build
proofpod: using Lean v4.35.0, the version Mathlib v4.35.0 is built for
```

Your files are not modified. In the cloud, ProofPod writes a
`.lake/package-overrides.json` that points Lake at the requested Mathlib and
its dependencies, and removes it again when you stop passing `--mathlib`. Your
`lake-manifest.json` and `lean-toolchain` stay as they are.

To make the change permanent, edit your lakefile and run `pp lake update`,
which updates the manifest and toolchain file on your machine.

### Try another Lean

```console theme={null}
$ pp --lean v4.37.0-rc1 lake build
$ pp lake +v4.37.0-rc1 build        # elan's syntax works too
```

### Without a project

Outside a Lake project, `pp lean File.lean` uploads just the files you name and
runs in a scratch workspace. Add `--mathlib` to make Mathlib importable:

```console theme={null}
$ cat Scratch.lean
import Mathlib
example : (2 : ℝ) ^ 10 = 1024 := by norm_num
$ pp --mathlib v4.36.0 lean Scratch.lean
```

## Projects without a manifest

A new project that has never been built has no `lake-manifest.json`, so there is
no exact Mathlib commit to match. Run this once:

```console theme={null}
$ pp lake update
proofpod: updated 1 local file(s) changed by the command: lake-manifest.json
```

It resolves your dependencies in the cloud and writes the manifest back to your
machine. Commit it. From then on your builds use the matching prebuilt
environment.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.