Zulip Chat Archive

Stream: general

Topic: lake exe shake --fix is broken


Yaël Dillies (May 09 2025 at 21:08):

It doesn't really work still. lake exe shake --fix in Toric returns a list of suggestions, but doesn't apply the import deletions. Funnily enough, it does apply the import additions!

Kevin Buzzard (May 10 2025 at 13:30):

I can confirm -- I just ran into this in FLT and whilst additions worked fine, I had to remove imports from 12 files manually after the fallout of some mathlib file splitting. Which repo should I open an issue against?

Yaël Dillies (May 10 2025 at 13:55):

shake is currently in mathlib

Kevin Buzzard (May 10 2025 at 14:05):

#24743

Yury G. Kudryashov (May 11 2025 at 06:55):

I have an impression that lake exe shake --fix doesn't remove any imports. It adds imports it shows in the log but doesn't remove them.

Yaël Dillies (May 11 2025 at 06:56):

See #general > Running lake exe shake in projects depending on mathlib

Yury G. Kudryashov (May 11 2025 at 06:56):

I see the same in Mathlib.

Yury G. Kudryashov (May 11 2025 at 06:57):

Marking this one as resolved so that we discuss this in 1 thread.

Notification Bot (May 11 2025 at 06:57):

Yury G. Kudryashov has marked this topic as resolved.

Notification Bot (May 11 2025 at 06:58):

Yaël Dillies has marked this topic as unresolved.

Yury G. Kudryashov (May 11 2025 at 07:00):

To other readers: the few messages above mean that I resolved this thread, then Yael unresolved it and moved relevant messages from the other thread here.

Kevin Buzzard (May 11 2025 at 09:09):

I opened #24743

Kim Morrison (May 15 2025 at 09:37):

@Mario Carneiro, unfortunately after your fix shake is now too aggressive, and removes more imports than desired.

Mario Carneiro (May 15 2025 at 12:57):

I didn't change the behavior of shake, it is as aggressive as it has always been

Mario Carneiro (May 15 2025 at 12:58):

Do you mean that it is not correctly identifying imports that it claims to want to remove?

Mario Carneiro (May 15 2025 at 12:59):

The issue was that the syntax of import changed due to Sebastian's work on the module system, and I think it has changed twice in quick succession (import private became private import), so you may have run into some intermediate state

Mac Malone (May 15 2025 at 15:44):

Mario Carneiro said:

import private became private import

import private became import all; private import is a separate feature.

Mario Carneiro (May 15 2025 at 15:44):

well either way the grammar changed twice

Kim Morrison (May 16 2025 at 05:12):

It looked to me that when it found an import to delete, it was deleting more than just that import. (Perhaps all following imports? I didn't look closely.)

Ruben Van de Velde (May 16 2025 at 05:24):

Do you remember where this happened?

Kim Morrison (May 16 2025 at 09:10):

It was on nightly-testing, see 3f35133e04a0206d158ecb9642003b6b94b23720

Ruben Van de Velde (May 16 2025 at 10:44):

$ lake exe shake --fix
The following changes will be made automatically:
Mathlib/Data/Part.lean:
  remove #[Mathlib.Algebra.Notation.Defs]
Successfully applied 1 suggestions.
$ git diff
diff --git Mathlib/Data/Part.lean Mathlib/Data/Part.lean
index 3d156636ef5..5273adad838 100644
--- Mathlib/Data/Part.lean
+++ Mathlib/Data/Part.lean
@@ -4,8 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro, Jeremy Avigad, Simon Hudon
 -/
 import Mathlib.Algebra.Notation.Defs
-import Mathlib.Data.Set.Subsingleton
-import Mathlib.Logic.Equiv.Defs

 /-!
 # Partial values of a type

Ruben Van de Velde (May 16 2025 at 10:46):

That certainly doesn't look right

Kevin Buzzard (May 16 2025 at 11:13):

Yes, "1 suggestions" should clearly be "1 suggestion" ;-)

Kevin Buzzard (May 20 2025 at 17:10):

Just to be clear, my clever-clever comment above isn't supposed to detract from the fact that lake exe shake --fix is now the most broken it has ever been, it now deletes random imports instead of the right ones

Yaël Dillies (May 20 2025 at 17:10):

May I bump this issue on top of @Mario Carneiro's radar? lake exe shake --fix currently misapplies the suggestions: When trying to delete import B in the following, it instead deletes imports C and D

import A
import B
import C
import D

Yaël Dillies (May 20 2025 at 17:11):

This makes it basically unusable :sad:

Mario Carneiro (May 20 2025 at 18:13):

Mario Carneiro said:

well either way the grammar changed twice

As I suspected, the issue is that the syntax changed yet again (3rd time's the charm?). To emphasize, this is not the same bug as #24743, it was fixed and then it was broken again in that time window

Mario Carneiro (May 20 2025 at 18:16):

#25054

Eric Wieser (May 20 2025 at 19:15):

What are the new syntax features for import?

Mario Carneiro (May 20 2025 at 19:15):

it now has both private and all

Mario Carneiro (May 20 2025 at 19:16):

private import all Foo is syntactically correct

Mario Carneiro (May 20 2025 at 19:16):

don't ask me what it does

Mario Carneiro (May 20 2025 at 19:17):

I added a self-test so the next time sebastian has a bright idea I won't get a call at 3am

Mario Carneiro (May 20 2025 at 19:17):

...figuratively speaking :grinning_face_with_smiling_eyes:

Eric Wieser (May 20 2025 at 19:17):

I would guess private means "downstream files don't see this" and all overrides that in imported files

Mario Carneiro (May 20 2025 at 19:18):

no, private import is more like open private from batteries, it means you get to see internal details from a module

Mario Carneiro (May 20 2025 at 19:18):

IIRC

Mario Carneiro (May 20 2025 at 19:41):

This just went from bors r+ to merged in 7 minutes. This is surprisingly fast?

Bryan Gin-ge Chen (May 20 2025 at 19:54):

CI is fast on changes that don't require recompiling mathlib :wink:

Mario Carneiro (May 20 2025 at 19:55):

I thought linting put a lower bound on simple changes

Mario Carneiro (May 20 2025 at 19:56):

has it really become so fast that it can be done in 2.5 minutes or are the expensive things like simp confluence not running anymore?

Aaron Liu (May 20 2025 at 20:10):

well you didn't mark anything @[simp]

Ruben Van de Velde (May 20 2025 at 20:11):

We don't cache lint checks

Mario Carneiro (May 20 2025 at 20:20):

Eric Wieser said:

I would guess private means "downstream files don't see this" and all overrides that in imported files

You are right. From the source (isExported = !private):

structure Import where
  module        : Name
  /-- `import all`; whether to import and expose all data saved by the module. -/
  importAll : Bool := false
  /-- Whether to activate this import when the current module itself is imported. -/
  isExported    : Bool := true
  deriving Repr, Inhabited, ToJson, FromJson

Edward van de Meent (May 20 2025 at 20:38):

maybe the idea for this is "you only need the tactics when compiling the file, not after"?

Mario Carneiro (May 20 2025 at 22:35):

I think it is also meant to include actual definitions and theorems used in setting up an API that isn't meant to be unfolded

Mario Carneiro (May 20 2025 at 22:36):

the key goal is to claw back the idea that lean imports are transitive

Mario Carneiro (May 20 2025 at 22:37):

hopefully eventually this may mean that you will not need to even load most of the thousands of files in the dependency tree because most of them are only used as dependencies of dependencies and nothing about them is visible to you

Yury G. Kudryashov (May 20 2025 at 22:43):

We should discuss whether we want to use this feature in mathlib, but not in this thread.

Mario Carneiro (May 21 2025 at 05:25):

well, much like grind, it's waiting for the FRO to actually officially announce it and open up at least a call for testing

Mario Carneiro (Jun 04 2025 at 20:44):

Mario Carneiro said:

Mario Carneiro said:

well either way the grammar changed twice

As I suspected, the issue is that the syntax changed yet again (3rd time's the charm?). To emphasize, this is not the same bug as #24743, it was fixed and then it was broken again in that time window

Third time was apparently not the charm: lean4#8598 will break shake again once it percolates through the system. At least this time shake will break at compile time so @Kim Morrison will have to ping me about it

Eric Wieser (Jun 30 2025 at 18:41):

If it's any consolation, lean --deps-json also can't quite parse its imports correctly: lean4#9111


Last updated: Dec 20 2025 at 21:32 UTC