Skip to content

Commit 774595b

Browse files
kim-emmathlib-nightly-testing[bot]leanprover-community-mathlib4-botRob23obakmill
committed
chore: adaptations for nightly-2026-03-17 (#200)
Co-authored-by: mathlib-nightly-testing[bot] <mathlib-nightly-testing[bot]@users.noreply.github.com> Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: Rob23oba <robin.arnez@web.de> Co-authored-by: Kyle Miller <kmill31415@gmail.com>
1 parent 3e08649 commit 774595b

5 files changed

Lines changed: 20 additions & 55 deletions

File tree

.github/workflows/build_template.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,23 +486,28 @@ jobs:
486486
rm -rf cache-staging
487487
mkdir -p cache-staging
488488
489+
# WORKAROUND: leantar v0.1.18 (bundled with Lean) uses tempfile::NamedTempFile::new()
490+
# which unconditionally writes to /tmp. We need --rw /tmp here until leantar is fixed
491+
# to use NamedTempFile::new_in() with an appropriate directory.
492+
# See: https://github.com/digama0/leangz/commit/6d1691e0a4
493+
# TODO: remove --rw /tmp once a fixed leantar is available
489494
- name: stage Mathlib cache files
490495
if: ${{ always() && (steps.build.outcome == 'success' || steps.build.outcome == 'failure' || steps.build.outcome == 'cancelled') }}
491-
shell: landrun --rox /usr --ro /etc/timezone --rw /dev --rox /home/lean/.elan --rox /home/lean/actions-runner/_work --rox /home/lean/.cache/mathlib/ --rw /home/lean/.cache/mathlib/ --rw pr-branch/.lake/ --rw cache-staging/ --env PATH --env HOME --env GITHUB_OUTPUT --env CI -- bash -euxo pipefail {0}
496+
shell: landrun --rox /usr --ro /etc/timezone --rw /dev --rw /tmp --rox /home/lean/.elan --rox /home/lean/actions-runner/_work --rox /home/lean/.cache/mathlib/ --rw /home/lean/.cache/mathlib/ --rw pr-branch/.lake/ --rw cache-staging/ --env PATH --env HOME --env GITHUB_OUTPUT --env CI -- bash -euxo pipefail {0}
492497
run: |
493498
cd pr-branch
494499
lake env ../tools-branch/.lake/build/bin/cache --staging-dir="../cache-staging" stage
495500
496501
- name: stage Archive cache files
497502
if: ${{ steps.archive.outcome == 'success' }}
498-
shell: landrun --rox /usr --ro /etc/timezone --rw /dev --rox /home/lean/.elan --rox /home/lean/actions-runner/_work --rox /home/lean/.cache/mathlib/ --rw /home/lean/.cache/mathlib/ --rw pr-branch/.lake/ --rw cache-staging/ --env PATH --env HOME --env GITHUB_OUTPUT --env CI -- bash -euxo pipefail {0}
503+
shell: landrun --rox /usr --ro /etc/timezone --rw /dev --rw /tmp --rox /home/lean/.elan --rox /home/lean/actions-runner/_work --rox /home/lean/.cache/mathlib/ --rw /home/lean/.cache/mathlib/ --rw pr-branch/.lake/ --rw cache-staging/ --env PATH --env HOME --env GITHUB_OUTPUT --env CI -- bash -euxo pipefail {0}
499504
run: |
500505
cd pr-branch
501506
lake env ../tools-branch/.lake/build/bin/cache --staging-dir="../cache-staging" stage Archive.lean
502507
503508
- name: stage Counterexamples cache files
504509
if: ${{ steps.counterexamples.outcome == 'success' }}
505-
shell: landrun --rox /usr --ro /etc/timezone --rw /dev --rox /home/lean/.elan --rox /home/lean/actions-runner/_work --rox /home/lean/.cache/mathlib/ --rw /home/lean/.cache/mathlib/ --rw pr-branch/.lake/ --rw cache-staging/ --env PATH --env HOME --env GITHUB_OUTPUT --env CI -- bash -euxo pipefail {0}
510+
shell: landrun --rox /usr --ro /etc/timezone --rw /dev --rw /tmp --rox /home/lean/.elan --rox /home/lean/actions-runner/_work --rox /home/lean/.cache/mathlib/ --rw /home/lean/.cache/mathlib/ --rw pr-branch/.lake/ --rw cache-staging/ --env PATH --env HOME --env GITHUB_OUTPUT --env CI -- bash -euxo pipefail {0}
506511
run: |
507512
cd pr-branch
508513
lake env ../tools-branch/.lake/build/bin/cache --staging-dir="../cache-staging" stage Counterexamples.lean

Cache/IO.lean

Lines changed: 10 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -79,24 +79,24 @@ def CURLBIN :=
7979
-- change file name if we ever need a more recent version to trigger re-download
8080
IO.CACHEDIR / s!"curl-{CURLVERSION}"
8181

82-
/-- leantar version at https://github.com/digama0/leangz -/
83-
def LEANTARVERSION :=
84-
"0.1.17"
85-
8682
def EXE := if System.Platform.isWindows then ".exe" else ""
8783

88-
def LEANTARBIN :=
89-
-- change file name if we ever need a more recent version to trigger re-download
90-
IO.CACHEDIR / s!"leantar-{LEANTARVERSION}{EXE}"
91-
9284
def LAKEPACKAGESDIR : FilePath :=
9385
".lake" / "packages"
9486

9587
def getCurl : IO String := do
9688
return if (← CURLBIN.pathExists) then CURLBIN.toString else "curl"
9789

98-
def getLeanTar : IO String := do
99-
return if (← LEANTARBIN.pathExists) then LEANTARBIN.toString else "leantar"
90+
/-- Path to the `leantar` binary bundled with the Lean toolchain.
91+
This has been bundled since `nightly-2026-03-09` (lean4#12822). -/
92+
private initialize leantarSysrootBin : String ← do
93+
let out ← IO.Process.output { cmd := "lean", args := #["--print-prefix"] }
94+
if out.exitCode == 0 then
95+
let path : FilePath := out.stdout.trimAscii.toString / "bin" / s!"leantar{EXE}"
96+
if ← path.pathExists then return path.toString
97+
throw <| IO.userError "leantar not found in Lean sysroot. This toolchain may predate nightly-2026-03-09."
98+
99+
def getLeanTar : IO String := return leantarSysrootBin
100100

101101
/-- Spawn a `leantar` process for decompression, writing the given JSON config to its stdin.
102102
Returns the process exit code. -/
@@ -238,45 +238,6 @@ def validateCurl : IO Bool := do
238238
| _ => throw <| IO.userError "Invalidly formatted version of `curl`"
239239
| _ => throw <| IO.userError "Invalidly formatted response from `curl --version`"
240240

241-
def Version := Nat × Nat × Nat
242-
deriving Inhabited, DecidableEq
243-
244-
instance : Ord Version := let _ := @lexOrd; lexOrd
245-
instance : LE Version := leOfOrd
246-
247-
def parseVersion (s : String) : Option Version := do
248-
let [maj, min, patch] := s.trimAscii.toString.splitOn "." | none
249-
some (← String.toNat? maj, ← String.toNat? min, ← String.toNat? patch)
250-
251-
def validateLeanTar : IO Unit := do
252-
if (← LEANTARBIN.pathExists) then return
253-
if let some version ← some <$> runCmd "leantar" #["--version"] <|> pure none then
254-
let "leantar" :: v :: _ := version.splitOn " "
255-
| throw <| IO.userError "Invalidly formatted response from `leantar --version`"
256-
let some v := parseVersion v | throw <| IO.userError "Invalidly formatted version of `leantar`"
257-
-- currently we need exactly one version of leantar, change this to reflect compatibility
258-
if v = (parseVersion LEANTARVERSION).get! then return
259-
let win := System.Platform.getIsWindows ()
260-
let target ← if win then
261-
pure "x86_64-pc-windows-msvc"
262-
else
263-
let mut arch ← (·.trimAscii.copy) <$> runCmd "uname" #["-m"] false
264-
if arch = "arm64" then arch := "aarch64"
265-
unless arch ∈ ["x86_64", "aarch64"] do
266-
throw <| IO.userError s!"unsupported architecture {arch}"
267-
pure <|
268-
if System.Platform.getIsOSX () then s!"{arch}-apple-darwin"
269-
else s!"{arch}-unknown-linux-musl"
270-
IO.println s!"installing leantar {LEANTARVERSION}"
271-
IO.FS.createDirAll IO.CACHEDIR
272-
let ext := if win then "zip" else "tar.gz"
273-
let _ ← runCmd "curl" (stderrAsErr := false) #[
274-
s!"https://github.com/digama0/leangz/releases/download/v{LEANTARVERSION}/leantar-v{LEANTARVERSION}-{target}.{ext}",
275-
"-L", "-o", s!"{LEANTARBIN}.{ext}"]
276-
let _ ← runCmd "tar" #["-xf", s!"{LEANTARBIN}.{ext}",
277-
"-C", IO.CACHEDIR.toString, "--strip-components=1"]
278-
IO.FS.rename (IO.CACHEDIR / s!"leantar{EXE}").toString LEANTARBIN.toString
279-
280241
/-- Recursively gets all files from a directory with a certain extension -/
281242
partial def getFilesWithExtension
282243
(fp : FilePath) (extension : String) (acc : Array FilePath := #[]) :

Cache/Main.lean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ def main (args : List String) : IO Unit := do
115115
let hashMemo ← getHashMemo roots
116116
let hashMap := hashMemo.hashMap
117117
let goodCurl ← pure !curlArgs.contains (args.headD "") <||> validateCurl
118-
if leanTarArgs.contains (args.headD "") then validateLeanTar
119118
let get (args : List String) (force := false) (decompress := true) := do
120119
let hashMap ← if args.isEmpty then pure hashMap else hashMemo.filterByRootModules roots.keys
121120
getFiles repo? hashMap force force goodCurl decompress skipProofWidgets

lake-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"type": "git",
6666
"subDir": null,
6767
"scope": "leanprover-community",
68-
"rev": "22f50046aa2bd8d7e31e066a274bfed54b079133",
68+
"rev": "b7558def110ca10bd6c97c1cbe8a80dbb3c86d8f",
6969
"name": "batteries",
7070
"manifestFile": "lake-manifest.json",
7171
"inputRev": "nightly-testing",

lean-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
leanprover/lean4:nightly-2026-03-14
1+
leanprover/lean4:nightly-2026-03-17

0 commit comments

Comments
 (0)