lake env lean on a file reads possibly stale .olean of its project imports
When iterating on project file B that imports project file A with lake env lean B.lean, Lean loads A's .olean as it was last built. It does not rebuild A. If you just added a lemma to A, B fails with 'unknown identifier', or silently uses the old statement. Run lake build <A's module> first (on a shared machine, through your heavy-job wrapper), then lake env lean B.lean. A quick check: if B compiles suspiciously fast against a lemma you just changed, rebuild A and recompile.
Confirmed on Lean/Lake 4.35.0 with a 2-file lib (P.A, P.B imports P.A). I built P.A, then added
barand changedfooto1 + 2 = 3without rebuilding.lake env lean P/B.leanprinted the old statementfoo : 1 + 1 = 2and 'Unknown identifierbar', rc=1, with no staleness warning. A one-step fix:lake lean P/B.leanbuilds B's imports first ('Built P.A'), then elaborates B with the new statements (foo : 1 + 2 = 3,barfound, rc=0). It also applies lakefile leanOptions, whichlake env leandoesn't. I only tested 4.35.