doc(README): document fetching Mathlib oleans #1081
For this section title, "Using CSLib in your project," I expect it to target people who just want to depend on CSLib. How to share local caches across checkouts and upload to a remote cache service are advanced or maintainer-level topics. Moreover, the remark that this repository doesn't do it in CI isn't relevant to a downstream user.
I ran some tests with cslib-community/fad, where I always tell students to use lake exe cache get after cloning:
lake exe cache get
lake build
The lake build time is usually 40-50 seconds after the cache has been downloaded.
But I confess I had never stopped to understand exactly how lake exe cache get works, and I didn't know about Lake's cache with LAKE_ARTIFACT_CACHE=true. So, from what I understood:
~/.cache/mathlib/*.ltar (compressed files, shared across projects)
│
│ lake exe cache get → downloads whatever is missing here and UNPACKS into ↓
▼
<project>/.lake/packages/mathlib/.lake/build/*.olean (inside each project)
▲
│ lake build → only looks here (and in Lake's cache)
(thanks Claude for the diagram)
Without LAKE_ARTIFACT_CACHE, lake exe cache get downloads the files to ~/.cache/mathlib/.ltar and then unpacks them into the project at <project>/.lake/packages/mathlib/.lake/build/.olean, so that lake build is then fast by looking at the project's oleans or Lake cache in ~/.elan/toolchains/.../lake/cache.
lake build will always check Lake's cache in ~/.elan/toolchains/.../lake/cache, from what I understood, regardless of the variable LAKE_ARTIFACT_CACHE being or not set.
With LAKE_ARTIFACT_CACHE=true, the oleans are not copied from Lake's cache into the project, unless we also have LAKE_RESTORE_ARTIFACTS=true. Without LAKE_ARTIFACT_CACHE, Lake's cache is copied into the project.
lake build only writes to Lake's cache in ~/.elan/toolchains/.../lake/cache if we have LAKE_ARTIFACT_CACHE=true.
Given that, we have
Fresh clone of fad
├─ toolchain cache has the right versions → lake build (copies from there, fast)
└─ it doesn't → lake exe cache get → lake build
└─ with LAKE_ARTIFACT_CACHE=true, this build also fills the toolchain cache
I recommend reducing the README changes to just summarize this understanding. Not sure we should mention the experimental lake cache yet.
But the README is not the place for an elaborate explanation of lake cache and lake exe cache (from Mahtlib). I guess we should just remind the user about lake exe cache get.
PS: Claude taught me a lot about the caches and helped me with tests, but I wrote all the above messages. Just to be clear. I got the English fixed by http://www.grammarly.com/!
arademaker
cdbattags
The "Using CSLib in your project" section (#206) stops at
lake update cslib. The nextlake buildthen compiles Mathlib. This addslake exe cache getthere, which is the same step Mathlib documents for downstream projects.lake exe cache getdoes not keep CSLib's own build products. The README also notesLAKE_ARTIFACT_CACHE=trueso another checkout of the same toolchain can reuse a local build, andLAKE_RESTORE_ARTIFACTS=truewhen a tool expects files under.lake/build.lake cache putis only described, not added to CI: it needsLAKE_CACHE_KEYand a cache service (LAKE_CACHE_SERVICE, orLAKE_CACHE_ARTIFACT_ENDPOINTwithLAKE_CACHE_REVISION_ENDPOINT).Drafted with Grok 4.7, the 500k-context high-effort setting, in Cursor. I used it to read
LAKE_ARTIFACT_CACHE,LAKE_RESTORE_ARTIFACTS, andLAKE_CACHE_KEYin Lean 4.35 (Lake.Config.Env,PackageConfig.enableArtifactCache) and to write the README paragraph. This repository has noLLM-generatedlabel; the disclosure above is the step CONTRIBUTING.md asks for, via the Mathlib policy.