Skip to content

Commit 9209df7

Browse files
committed
chore: only run post_update hook when versions match (leanprover-community#30956)
See [#lean4 > Lake new errors @ 💬](https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/Lake.20new.20errors/near/547175291)
1 parent ac430c1 commit 9209df7

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

lakefile.lean

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,17 @@ post_update pkg do
159159
if rootPkg.name = pkg.name then
160160
return -- do not run in Mathlib itself
161161
if (← IO.getEnv "MATHLIB_NO_CACHE_ON_UPDATE") != some "1" then
162+
-- Check if Lake version matches toolchain version
163+
let toolchainFile := rootPkg.dir / "lean-toolchain"
164+
let toolchainContent ← IO.FS.readFile toolchainFile
165+
let toolchainVersion := match toolchainContent.trim.splitOn ":" with
166+
| [_, version] => version
167+
| _ => toolchainContent.trim -- fallback to full content if format is unexpected
168+
if Lean.versionString ≠ toolchainVersion then
169+
IO.println s!"Not running `lake exe cache get` yet, \
170+
as the `lake` version does not match the toolchain version in the project.\n\
171+
You should run `lake exe cache get` manually."
172+
return
162173
let exeFile ← runBuild cache.fetch
163174
-- Run the command in the root package directory,
164175
-- which is the one that holds the .lake folder and lean-toolchain file.

0 commit comments

Comments
 (0)