Zulip Chat Archive
Stream: mathlib4
Topic: Ensuring a repo builds on top of mathlib PRs
Geoffrey Irving (Oct 14 2023 at 14:19):
If I have an existing lake repo, and move some of its theorems into a mathlib PR, how does one best ensure the repo builds on top of the PR? Should I make the branch inside the lake-packages directory, or would that be clobbered?
Yaël Dillies (Oct 14 2023 at 14:22):
I usually make sure everything builds before I first open the PR and don't bother fixing downstream stuff every time someone asks for a change.
Yaël Dillies (Oct 14 2023 at 14:22):
You can also make your project depend on a specific commit of mathlib, be it on master
or on your PR.
Geoffrey Irving (Oct 14 2023 at 14:32):
Everything builds already, so roughly I’ve already done step one. Yoloing the rest is okay I suppose.
Jon Eugster (Oct 14 2023 at 15:01):
Concretely, the "correct" way to do this is to modify the lakefile.lean
of your project to contain
require mathlib from git
"https://github.com/leanprover-community/mathlib4" @ "7d308680dc444730e84a86c72357ad9a7aea9c4b"
where you specify the commit of the mathlib-PR you build on. That way you can use the cache that CI built for the PR
Then you call the usual
lake update
lake exe cache get
lake build
in your project.
Don't do any manual git-stuff inside lake-packages
, that will only be prone to problems down the line.
Geoffrey Irving (Oct 14 2023 at 17:35):
The cache never works for me (on M1 or M2 Mac); not sure if that’s expected.
Anatole Dedecker (Oct 14 2023 at 18:29):
No that’s not! If you’re going to work on mathlib we should definitely work on solving that
Geoffrey Irving (Oct 14 2023 at 19:37):
Fixed: This was just me not running the command (I hadn't tried since learning it didn't work on Lean 3).
Edit: No, still doesn't work in the ray
repo. It works fine for mathlib
itself, though, so I'm not immediately blocked.
Yaël Dillies (Oct 14 2023 at 20:02):
What do you mean by "doesn't work on the ray
repo"? Do you mean the whole command fails when you call it inside the ray
repo, or that is doesn't find cache for the ray
repo but does find cache for mathlib? The latter is expected: you probably haven't set up a caching mechanism for your repo. The former would be quite bad and unexpected.
Geoffrey Irving (Oct 14 2023 at 20:09):
It downloads cached files without complaint, but then for some reason it proceeds to build 1800 mathlib files anyways on lake build
. Here is a from scratch reproduction...no, actually checking out a fresh repo at the same CL doesn't have the same problem. So somehow my checkout is corrupted, and this seems not worth chasing down.
Fixed!
Yaël Dillies (Oct 14 2023 at 20:09):
Just in case you don't know about it, lake exe cache get!
forces the redownload of all files.
Geoffrey Irving (Oct 14 2023 at 20:11):
Great, that seems to have fixed the initial repo too. :)
Scott Morrison (Oct 14 2023 at 23:57):
(And often merely lake clean && lake exe cache get
suffices, but lake clean && lake exe cache get!
is even more thorough!)
Last updated: Dec 20 2023 at 11:08 UTC