Zulip Chat Archive
Stream: new members
Topic: Does importing dependency as git repository clone submodules
Srayan Jana (Sep 20 2025 at 00:18):
Title says it all.
If i have a Lean project that I want to import as a git repo, will it also import all of the submodules as well?
Aaron Liu (Sep 20 2025 at 00:18):
no I don't think so
Aaron Liu (Sep 20 2025 at 00:18):
I guess it depends on what you mean by "import as a git repo"
Srayan Jana (Sep 20 2025 at 00:26):
@Aaron Liu Like as part of the lakefile
https://lean-lang.org/doc/reference/4.19.0/Build-Tools-and-Distribution/Lake/#The-Lean-Language-Reference--Build-Tools-and-Distribution--Lake--Configuration-File-Format--Lean-Format--Dependencies
Aaron Liu (Sep 20 2025 at 00:27):
I don't think that imports anything by itself
Srayan Jana (Sep 20 2025 at 00:27):
Aaron Liu (Sep 20 2025 at 00:27):
it just adds the dependency to your project
Srayan Jana (Sep 20 2025 at 00:27):
Yeah does that dependency include git submodules?
Srayan Jana (Sep 20 2025 at 00:27):
[[require]]
name = "example"
git = "https://git.example.com/example.git"
rev = "main"
version = "2.12"
Aaron Liu (Sep 20 2025 at 00:27):
so when building your project lake will checkout the repository
Aaron Liu (Sep 20 2025 at 00:27):
Srayan Jana said:
Yeah does that dependency include git submodules?
I don't know what that is
Aaron Liu (Sep 20 2025 at 00:29):
I looked it up and it seems very weird
Aaron Liu (Sep 20 2025 at 00:29):
you have another repo inside your repo?
Srayan Jana (Sep 20 2025 at 00:29):
Yes, its a pretty common feature for git repositories.
Aaron Liu (Sep 20 2025 at 00:29):
I don't know why you would do that for a Lean project
Srayan Jana (Sep 20 2025 at 00:30):
I'm working on SDL bindings for lean and I need a way to link Lean to SDL's git repo, so I have SDL as a gitsubmodule
https://github.com/oOo0oOo/LeanDoomed/tree/main/vendor
Aaron Liu (Sep 20 2025 at 00:31):
interesting
Srayan Jana (Sep 20 2025 at 00:31):
https://github.com/oOo0oOo/LeanDoomed/blob/main/.gitmodules
Aaron Liu (Sep 20 2025 at 00:31):
I will try to find out if this will affect anything
Srayan Jana (Sep 20 2025 at 00:34):
@Aaron Liu https://github.com/Ravbug/sdl3-sample/tree/main
here's a C++ project that uses submodules as dependencies, and update the repositories every so often
Aaron Liu (Sep 20 2025 at 00:34):
I think it clones the repo so whatever that does
Aaron Liu (Sep 20 2025 at 00:37):
probably relevant
https://github.com/leanprover/lean4/blob/c6abc3c0368e10c49e9762fda1819ad0e95c9bb0/src/lake/Lake/Util/Git.lean#L65-L66
https://github.com/leanprover/lean4/blob/c6abc3c0368e10c49e9762fda1819ad0e95c9bb0/src/lake/Lake/Load/Materialize.lean#L38-L47
https://github.com/leanprover/lean4/blob/c6abc3c0368e10c49e9762fda1819ad0e95c9bb0/src/lake/Lake/DSL/Syntax.lean#L125-L129
Srayan Jana (Sep 20 2025 at 00:47):
oof it doesnt seem to clone the submodules, thats a big issue.
There should be a command being called that looks something like
git submodule update --init --recursive
https://stackoverflow.com/a/10168693
Srayan Jana (Sep 20 2025 at 00:47):
it should be called right after git clone is called on the repository
Anthony Wang (Sep 20 2025 at 00:48):
Aaron Liu said:
I don't know why you would do that for a Lean project
I've seen at least one Lean project with submodules, for instance https://github.com/leanprover/SampCert/blob/main/.gitmodules
Anthony Wang (Sep 20 2025 at 00:50):
If you clone using git clone --recursive then it will also clone the submodules so you don't have to run that git submodule command manually, but it looks like lake doesn't do that, based on the https://github.com/leanprover/lean4/blob/c6abc3c0368e10c49e9762fda1819ad0e95c9bb0/src/lake/Lake/Util/Git.lean#L65-L66 link that @Aaron Liu sent.
Srayan Jana (Sep 20 2025 at 00:53):
https://github.com/leanprover/lean4/issues/10467
made an issue, this should be a pretty easy fix/thing to test
Srayan Jana (Sep 20 2025 at 02:37):
Made a test project to show that it doesn't work: https://github.com/ValorZard/Test-Lean-Git-Submodule
(it doesn't compile for other reasons, but you can see that it never fills out the gits ubmodule in ".lake\packages\SampCert\Tests\IBM"
Julian Berman (Sep 21 2025 at 15:11):
In the interim switching to subtrees (which are anyhow better :devil: ) is a workaround just in case you haven't considered that.
Last updated: Dec 20 2025 at 21:32 UTC