Zulip Chat Archive
Stream: new members
Topic: Forgetting to add new files to the project’s root file
Isak Colboubrani (Mar 19 2025 at 22:47):
Whenever I add a new file, NewFile.lean
, to the project ProjectName
using VS Code’s “New File…” command, I also need to remember to manually add import ProjectName.NewFile
in the root file ProjectName.lean
to have NewFile.lean
built by lake build
.
This generally works, but it’s easy to forget that second manual step. When that happens, NewFile.lean
may appear to work fine in VS Code, yet remain omitted from the lake build
.
As a result, lake build
won’t flag issues such as the presence of sorry
in NewFile.lean
, which can falsely suggest that the project is in better shape than it really is.
Am I the only one who sometimes forgets to add new files to the project’s root file?
Is there an effective way to prevent this issue? Something like import ProjectName.*
isn’t currently possible?
Eric Wieser (Mar 19 2025 at 22:48):
You can skip the top level file entirely and tell lake to build all subfiles
Eric Wieser (Mar 19 2025 at 22:49):
The syntax for doing so depends on if you have a lean or toml lakefile
Isak Colboubrani (Mar 19 2025 at 22:52):
That's great news!
I'm using the standard lakefile.toml
provided by lake new project-name math
.
Eric Wieser (Mar 19 2025 at 23:00):
I believe the syntax is globs = ["MyProject.+"]
in the lean_lib
target, but I don't remember how to find the docs
Isak Colboubrani (Mar 19 2025 at 23:05):
I found this: https://github.com/leanprover/lean4/blob/master/src/lake/README.md#defining-build-targets
Isak Colboubrani (Mar 19 2025 at 23:05):
globs
: AnArray
of moduleGlob
(s) to build for the library. The termglob
comes from file globs (e.g.,foo/*
) on Unix. A submodule glob builds every Lean source file within the module's directory (i.e.,Glob.submodules `Foo
is essentially equivalent to a theoreticalimport Foo.*
). Local imports of glob'ed files (i.e., fellow modules of the workspace) are also recursively built. Defaults to aGlob.one
of each of the library'sroots
.
Eric Wieser (Mar 19 2025 at 23:10):
That's the .lean docs, the .toml ones might not yet exist
Kevin Buzzard (Mar 19 2025 at 23:28):
The FLT toml looks like https://github.com/ImperialCollegeLondon/FLT/blob/main/lakefile.toml and that builds everything in FLT whether or not it's in that crazy FLT.lean file (which I autogenerate with lake exe mk_all
BTW)
Last updated: May 02 2025 at 03:31 UTC