Zulip Chat Archive
Stream: new members
Topic: Git question
Freek Wiedijk (Apr 25 2024 at 11:54):
I decided to give Lean another try (the system is a bit impolite, but I'll try to ignore this). My current question is that in vscode on my arm debian after I create a fresh project I get a blue circle with a one on the git icon, and if I do "git status" it tells me "modified: .lake/packages/Cli (untracked content)". So what should I do to get rid of that blue one? My knowledge of vscode and git is not sufficient to decide what is the best approach for this.
Gareth Ma (Apr 25 2024 at 11:55):
Please open a "new conversation"
Gareth Ma (Apr 25 2024 at 11:55):
Screenshot-2024-04-25-at-12.55.04.png
By clicking this button
Freek Wiedijk (Apr 25 2024 at 11:55):
As will be clear I'm a newbie. How do I remove that message?
Gareth Ma (Apr 25 2024 at 11:55):
You can hover over a message and press either delete or "move message"
Notification Bot (Apr 25 2024 at 11:56):
5 messages were moved here from #new members > Floor division hell in asymptotics by Freek Wiedijk.
Freek Wiedijk (Apr 25 2024 at 11:58):
Gareth Ma said:
Screenshot-2024-04-25-at-12.55.04.png
By clicking this button
I don't see that button. Should I just change the topic before pressing the blue button on the right?
Screenshot-2024-04-25-at-13.58.18.png
Ruben Van de Velde (Apr 25 2024 at 12:03):
Okay, it worked
Ruben Van de Velde (Apr 25 2024 at 12:04):
Now that git message sounds a little odd. How did you create the new project?
Freek Wiedijk (Apr 25 2024 at 12:04):
I was using a web browser, but now installed an app. Let's see whether that works more easily for me.
Freek Wiedijk (Apr 25 2024 at 12:05):
And I still would like an answer to my git question :smile:
Freek Wiedijk (Apr 25 2024 at 12:07):
(deleted)
Ruben Van de Velde (Apr 25 2024 at 12:07):
Yeah, that's... a choice :)
Ruben Van de Velde (Apr 25 2024 at 12:08):
Ruben Van de Velde said:
Now that git message sounds a little odd. How did you create the new project?
So how about this?
Freek Wiedijk (Apr 25 2024 at 12:11):
Ah, I missed that reply, sorry. I did lake new lean4 math
, then cd lean4
, then lake update
, then lake exe cache get
, then git commit -a
, then git status
.
Ruben Van de Velde (Apr 25 2024 at 12:11):
Let me try that
Freek Wiedijk (Apr 25 2024 at 12:12):
Actually instead of git commit -a
I clicked inside code
, to get rid of the blue number on the git icon.
Richard Osborn (Apr 25 2024 at 12:12):
You need to add /.lake/
to your .gitignore
file.
Freek Wiedijk (Apr 25 2024 at 12:14):
I can do that, but why did lake new ...
not put it there? Currently the contents are:
/lake-packages/*```
Ruben Van de Velde (Apr 25 2024 at 12:14):
The location of dependencies changed, apparently this wasn't updated
Freek Wiedijk (Apr 25 2024 at 12:15):
Ruben Van de Velde said:
Let me try that
Did you get the same behavior, or does it have something to do with my setup?
Richard Osborn (Apr 25 2024 at 12:15):
Also, your git commit -a
staged those files in .lake
which isn't advisable.
Ruben Van de Velde (Apr 25 2024 at 12:15):
I did get the same outcome
Ruben Van de Velde (Apr 25 2024 at 12:16):
Which is really odd, because the other dependencies got added, but only Cli is still marked as pending change
Freek Wiedijk (Apr 25 2024 at 12:17):
Richard Osborn said:
Also, your
git commit -a
staged those files in.lake
which isn't advisable.
I don't think it did, as it is "untracked content"?
Ruben Van de Velde (Apr 25 2024 at 12:17):
If you do git log --stat
, I think you'll see that you added a number of things under .lake
Freek Wiedijk (Apr 25 2024 at 12:18):
Richard Osborn said:
You need to add
/.lake/
to your.gitignore
file.
Should this be /.lake/
or /.lake
or /.lake/*
or doesn't it matter?
Ruben Van de Velde (Apr 25 2024 at 12:18):
I'm not sure it matters, but mathlib uses /.lake/
Freek Wiedijk (Apr 25 2024 at 12:20):
Ruben Van de Velde said:
If you do
git log --stat
, I think you'll see that you added a number of things under.lake
Yes. mathlib
for example! But apparently that had a different status from Cli
. So should I start fresh, and add this /.lake/
line to .gitignore
before making my initial commit?
Richard Osborn (Apr 25 2024 at 12:21):
just type git undo
and you should be fine
Ruben Van de Velde (Apr 25 2024 at 12:21):
I would start fresh, yeah, but use the first command in https://github.com/leanprover-community/mathlib4/wiki/Using-mathlib4-as-a-dependency
Ruben Van de Velde (Apr 25 2024 at 12:21):
That will get you a correct gitignore
Freek Wiedijk (Apr 25 2024 at 12:22):
Ruben Van de Velde said:
I would start fresh, yeah, but use the first command in https://github.com/leanprover-community/mathlib4/wiki/Using-mathlib4-as-a-dependency
Okay, I'll do so, thanks for the help, and thanks for the pointer to the correct command. The lake update
and lake exe cache get
are still correct, and should be given explicitly after?
Ruben Van de Velde (Apr 25 2024 at 12:23):
I think lake update
will not do anything at this point, because lake new
should get the newest version of mathlib anyway, but it won't hurt
Ruben Van de Velde (Apr 25 2024 at 12:24):
Definitely use lake exe cache get
to get a precompiled version of mathlib
Freek Wiedijk (Apr 25 2024 at 12:24):
It's taking time, so I think it's doing something. I think mathlib was not downloaded yet.
Ruben Van de Velde (Apr 25 2024 at 12:26):
Oh yes, it looks like I was wrong and lake update
does do something at this point
Freek Wiedijk (Apr 25 2024 at 12:27):
git status
now says:
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
Lean4.lean
Lean4/
lake-manifest.json
lakefile.lean
lean-toolchain
nothing added to commit but untracked files present (use "git add" to track)
Which of those should I add to .gitignore
, and which should I git add
? Or can I just go into code
, and will it do the right thing for me?
Freek Wiedijk (Apr 25 2024 at 12:27):
I guess the Lean4
stuff is because I called the project lean4
?
Ruben Van de Velde (Apr 25 2024 at 12:29):
Yes, exactly. You should add all of those
Freek Wiedijk (Apr 25 2024 at 12:29):
And the lean-toolchain
file says leanprover/lean4:v4.7.0
. Does that mean that the project won't automatically move versions if a newer version of lean4 comes out?
Ruben Van de Velde (Apr 25 2024 at 12:29):
That's correct
Freek Wiedijk (Apr 25 2024 at 12:29):
So what is the lake
command to move to a newer lean
?
Freek Wiedijk (Apr 25 2024 at 12:30):
Or to pull the most recent version of mathlib for that matter?
Richard Osborn (Apr 25 2024 at 12:30):
I believe you just need to edit that file (and run lake update
)
Ruben Van de Velde (Apr 25 2024 at 12:30):
lake update
will update mathlib, and I think it now automatically updates lean-toolchain
to match mathlib
Freek Wiedijk (Apr 25 2024 at 12:31):
That sounds great, thanks for all the help.
Freek Wiedijk (Apr 25 2024 at 12:31):
Sorry for all the questions, but as this is a newbie channel, I hope I shouldn't feel too embarrassed about it.
Ruben Van de Velde (Apr 25 2024 at 12:31):
Lean4 is still changing quite a lot in ways that need accompanying mathlib changes, so you want to use a matching version
Ruben Van de Velde (Apr 25 2024 at 12:32):
No worries, that's what this stream is for
Freek Wiedijk (Apr 25 2024 at 12:32):
So I should just do lake update
occassionally? I'll try to remember that.
Freek Wiedijk (Apr 25 2024 at 12:33):
If I do lake update
I get:
warning: Qq: ignoring missing dependency manifest './.lake/packages/Qq/lake-manifest.json'
warning: Cli: ignoring missing dependency manifest './.lake/packages/Cli/lake-manifest.json'
Should I worry about that? I like my life to be warning-free.
Freek Wiedijk (Apr 25 2024 at 12:34):
But maybe being warning-free is something a Lean-user should not aspire to? :smile:
Marc Huisinga (Apr 25 2024 at 12:35):
By the way, a way to go through all these steps without the terminal is to open VS Code, open an empty text document and then click the following button:
image.png
That should set up your project depending on Mathlib for you with the correct toolchain, run lake update
, lake exe get cache
and create an initial commit with all these files.
Freek Wiedijk (Apr 25 2024 at 12:36):
Good to know, I'll try that next time :smile:
Marc Huisinga (Apr 25 2024 at 12:37):
Freek Wiedijk said:
If I do
lake update
I get:warning: Qq: ignoring missing dependency manifest './.lake/packages/Qq/lake-manifest.json' warning: Cli: ignoring missing dependency manifest './.lake/packages/Cli/lake-manifest.json'
Should I worry about that? I like my life to be warning-free.
No, you don't need to worry about it. I should probably just go ahead and add a lake-manifest.json
file to lean4-cli already!
Freek Wiedijk (Apr 25 2024 at 12:38):
Just an empty file?
Marc Huisinga (Apr 25 2024 at 12:39):
To be clear, this is nothing you should do, but something that I should do for the repository behind Cli
.
It won't be quite an empty file, but close to one :-)
Freek Wiedijk (Apr 25 2024 at 12:43):
And not for Qq
? So how do I get rid of those warnings then?
Mario Carneiro (Apr 25 2024 at 12:43):
these are issues in the upstream dependencies. Honestly it's not great that lake is bugging users about it, because there is nothing you can do to fix it short of forking the dependency
Marc Huisinga (Apr 25 2024 at 12:44):
Or, less drastically, bug the maintainer to fix it
Freek Wiedijk (Apr 25 2024 at 12:45):
Like I said at the very start: occasionally impolite :smile: I'll ignore the warnings then for now. Thanks for all the help!
Freek Wiedijk (Apr 25 2024 at 12:45):
Marc Huisinga said:
Or, less drastically, bug the maintainer to fix it
Which apparently I have just done :grin:
Mario Carneiro (Apr 25 2024 at 12:45):
By the way, the issue you had with lake-packages
showing up in the gitignore instead of .lake
is evidence that you used an old lake
version to run lake new
Mario Carneiro (Apr 25 2024 at 12:46):
which makes sense, this is a frequent issue for people coming back to lean after a hiatus
Freek Wiedijk (Apr 25 2024 at 12:46):
That's probably true then. So how do I update my lake?
Mario Carneiro (Apr 25 2024 at 12:46):
elan update stable
IIRC
Freek Wiedijk (Apr 25 2024 at 12:46):
And should I update my lean4 too?
Mario Carneiro (Apr 25 2024 at 12:46):
it does both
Mario Carneiro (Apr 25 2024 at 12:47):
although for lean itself it doesn't matter as much because once you are in a project the lean-toolchain file overrides whatever you have set locally
Mario Carneiro (Apr 25 2024 at 12:47):
lake new
is special because it's the only lean command you are likely to run outside the context of a project
Freek Wiedijk (Apr 25 2024 at 12:47):
So are there two lean4s then, one for my system and one for my project? That seems wasteful. Can I get rid of the global one then?
Mario Carneiro (Apr 25 2024 at 12:48):
there are much more than two :)
Mario Carneiro (Apr 25 2024 at 12:48):
elan holds all versions of lean that you have had cause to use, you can see them with elan toolchain list
Freek Wiedijk (Apr 25 2024 at 12:48):
Guest. I'll be back later.
Mario Carneiro (Apr 25 2024 at 12:50):
The lean version used by your project is not stored in the project, it is stored in the .elan
folder. So if you have multiple projects on the same version of lean you won't have two leans installed for those, but if you have two projects with different versions of lean then elan will cache them both
Freek Wiedijk (Apr 25 2024 at 13:44):
Ah yes, I see a lot of junk in that .elan/toolchains
:
leanprover-community--lean---3.51.1 leanprover--lean4---v4.3.0-rc1
leanprover--lean4---nightly leanprover--lean4---v4.7.0
leanprover--lean4---nightly-2023-02-04 leanprover--lean4---v4.7.0-rc2
leanprover--lean4---nightly-2023-06-20 stable
leanprover--lean4---stable
Is there a way to remove unused versions to clean up some space on my system?
Freek Wiedijk (Apr 25 2024 at 13:46):
I see a stable
and a leanprover--lean4---stable
and a lot of versions. I would have expected those stables to be symbolic links, but they aren't? Which versions are those then?
Freek Wiedijk (Apr 25 2024 at 13:48):
And the executables in ~/.elan/bin
all seem links to the same file. Is that in one of those toolchains as well?
Freek Wiedijk (Apr 25 2024 at 13:48):
Sorry, but I'd like to have some idea what Lean is sprinkling around my system :smile:
Kevin Buzzard (Apr 25 2024 at 13:49):
Do you know about .mathlib
?
Marc Huisinga (Apr 25 2024 at 13:50):
Freek Wiedijk said:
I see a
stable
and aleanprover--lean4---stable
and a lot of versions. I would have expected those stables to be symbolic links, but they aren't? Which versions are those then?
They're whatever version the respective toolchain resolved to at the time of installation. Improving this is https://github.com/leanprover/elan/pull/106, but unfortunately nobody has extensively tested this change yet, and Sebastian hasn't had time to work on Elan for a while.
Freek Wiedijk (Apr 25 2024 at 13:52):
Kevin Buzzard said:
Do you know about
.mathlib
?
Ah, another unexpected hidden directory in my homedir... That's just 250M, the mathlib of the project is in .lake/packages/mathlib
, I think? That's why I want just one project (with subdirectories for my actual project), which is why I called it lean4
instead of something meaningful.
Marc Huisinga (Apr 25 2024 at 13:53):
Freek Wiedijk said:
And the executables in
~/.elan/bin
all seem links to the same file. Is that in one of those toolchains as well?
.elan/toolchains
contains the toolchains, .elan/bin
is what is called when you call lean
, lake
etc., which then calls the correct toolchain binary (e.g. in a folder with a lean-toolchain
file, it uses the one designated in that file).
Freek Wiedijk (Apr 25 2024 at 13:53):
I see, thanks, that makes sense.
Freek Wiedijk (Apr 25 2024 at 13:54):
So if I just delete all toolchains from .elan/toolchains
apart from the one that is in the lean-toolchain
file of my project, will I break anything?
Freek Wiedijk (Apr 25 2024 at 13:55):
Those files in ~/.elan/bin
are 12M, that's a lot of binary for such shallow functionality (just finding the right toolchain, and invoking what's there?) I guess they're programmed in Lean? :smile:
Freek Wiedijk (Apr 25 2024 at 13:56):
(deleted)
Marc Huisinga (Apr 25 2024 at 13:57):
I think I'd make sure that your default toolchain is the same as the one in your project first (elan show
tells you what it is and you can set it with elan default <...>
), but after that, deleting unused toolchains should be fine.
Alternatively, you can also use elan toolchain uninstall <...>
to uninstall toolchains from the CLI.
Freek Wiedijk said:
Those files in
~/.elan/bin
are 12M, that's a lot of binary for such shallow functionality. I guess they're programmed in Lean? :smile:
Elan is a Rust project and was originally forked from rustup.
Freek Wiedijk (Apr 25 2024 at 13:59):
Will the elan toolchain uninstall ...
do more than just removing those directories (like update some configuration files)?
Freek Wiedijk (Apr 25 2024 at 14:00):
And, as Kevin pointed out: can I just clean out the .tar.gz
s in .mathlib
? Is that Lean3 or Lean4 stuff?
Marc Huisinga (Apr 25 2024 at 14:00):
Freek Wiedijk said:
Will the
elan toolchain uninstall ...
do more than just removing those directories (like update some configuration files)?
I don't think so. I'm pretty sure that I've used both in the past before.
Mario Carneiro (Apr 25 2024 at 14:09):
elan toolchain uninstall
removes the directory from .elan/toolchains
and also removes a file from update-hashes
. If you do only the former without the latter then elan will enter a bad state, this is a common issue since it's natural to nuke the big folder and forget to clean up the config (not sure if there is an issue tracking this though or if it has since been fixed)
Freek Wiedijk (Apr 25 2024 at 14:10):
Ouch! I just deleted all those subdirs. If I delete the corresponding ones from update-hashes
I'm fine again?
Mario Carneiro (Apr 25 2024 at 14:11):
I believe so
Freek Wiedijk (Apr 25 2024 at 14:11):
Okay, thanks, I'll do so now then.
Freek Wiedijk (Apr 25 2024 at 14:12):
ls -ld */*
in .elan
now says:
-rwxr-xr-x 7 freek freek 12136504 Apr 25 14:40 bin/elan
-rwxr-xr-x 7 freek freek 12136504 Apr 25 14:40 bin/lake
-rwxr-xr-x 7 freek freek 12136504 Apr 25 14:40 bin/lean
-rwxr-xr-x 7 freek freek 12136504 Apr 25 14:40 bin/leanc
-rwxr-xr-x 7 freek freek 12136504 Apr 25 14:40 bin/leanchecker
-rwxr-xr-x 7 freek freek 12136504 Apr 25 14:40 bin/leanmake
-rwxr-xr-x 7 freek freek 12136504 Apr 25 14:40 bin/leanpkg
drwxr-xr-x 7 freek freek 4096 Apr 25 13:44 toolchains/leanprover--lean4---v4.7.0
-rw-r--r-- 1 freek freek 67 Apr 25 13:44 update-hashes/leanprover--lean4---v4.7.0
I hope I didn't delete too much :smile:
Mario Carneiro (Apr 25 2024 at 14:13):
What happens if you run lake --help
outside a lean project?
Freek Wiedijk (Apr 25 2024 at 14:16):
Lake version 5.0.0-6fce8f7 (Lean version 4.7.0)
USAGE:
lake [OPTIONS] <COMMAND>
COMMANDS:
new <name> <temp> create a Lean package in a new directory
init <name> <temp> create a Lean package in the current directory
build <targets>... build targets
exe <exe> <args>... build an exe and run it in Lake's environment
clean remove build outputs
env <cmd> <args>... execute a command in Lake's environment
update update dependencies and save them to the manifest
upload <tag> upload build artifacts to a GitHub release
script manage and run workspace scripts
scripts shorthand for `lake script list`
run <script> shorthand for `lake script run`
serve start the Lean language server
OPTIONS:
--version print version and exit
--help, -h print help of the program or a command and exit
--dir, -d=file use the package configuration in a specific directory
--file, -f=file use a specific file for the package configuration
--quiet, -q hide progress messages
--verbose, -v show verbose information (command invocations)
--lean=cmd specify the `lean` command used by Lake
-K key[=value] set the configuration file option named key
--old only rebuild modified modules (ignore transitive deps)
--rehash, -H hash all files for traces (do not trust `.hash` files)
--update, -U update manifest before building
--reconfigure, -R elaborate configuration files instead of using OLeans
See `lake help <command>` for more information on a specific command.
Mario Carneiro (Apr 25 2024 at 14:20):
in that case I think you're good
Mario Carneiro (Apr 25 2024 at 14:21):
elan will automatically install new toolchains as needed if you try to compile a project on a different version
Mario Carneiro (Apr 25 2024 at 14:21):
it's rare to need to do elan toolchain install
directly
Freek Wiedijk (Apr 25 2024 at 14:30):
Freek Wiedijk said:
And, as Kevin pointed out: can I just clean out the
.tar.gz
s in~/.mathlib
? Is that Lean3 or Lean4 stuff?
So can I remove those files, that look like they're intermediate files for installing something?
Mario Carneiro (Apr 25 2024 at 14:32):
I don't think anything in lean 4 uses .mathlib
. IIRC that's the path used for leanproject get-cache
which is lean 3
Freek Wiedijk (Apr 25 2024 at 14:33):
Mario Carneiro said:
I don't think anything in lean 4 uses
.mathlib
. IIRC that's the path used forleanproject get-cache
which is lean 3
I'm not interested in Lean 3. So I'll remove that directory then.
Mario Carneiro (Apr 25 2024 at 14:33):
However you should watch .cache/mathlib
, which contains mathlib4 cache files
Mario Carneiro (Apr 25 2024 at 14:34):
in both cases it's just a cache, you can freely delete things and they will just be re-downloaded if needed
Freek Wiedijk (Apr 25 2024 at 14:34):
One gigabyte! Okay, so I'll remove those files also then.
Mario Carneiro (Apr 25 2024 at 14:35):
IIRC there are about 400 MB of cache files downloaded for one mathlib
Mario Carneiro (Apr 25 2024 at 14:35):
and these unpack to about 4 GB inside each mathlib-depending project
Mario Carneiro (Apr 25 2024 at 14:35):
(yes, lean4+mathlib is chunky)
Last updated: May 02 2025 at 03:31 UTC