Zulip Chat Archive
Stream: general
Topic: system-wide install
Miguel Marco (Jul 17 2023 at 14:28):
I am trying to install Lean4+mathlib in the jupyter server we use for teaching.
It is a system where students access with their university credentials, and have a system user associated to them.
Thanks to the vscode-server proxy extension, each student, once logged in, can start a web version of vscode. Now we need to install lean+mathlib in a way that is accessible to every user.
From what i have seen, the elan approach is to install everything at user level. That is, each students should run the corresponding script, initialize a project and so on.
Is there a way to do that steps on a system level, so that each user just has to log in and have a working lean+mathlib environment?
Mac Malone (Jul 19 2023 at 03:49):
To get elan
working at a system level, you may be able to just install it as whatever system user is running the vscode-server
. VSCode should then make use of that lean toolchain. This would get a Lean 4 environment for students to use, and VS Code's embedded terminal should allow them to make use of elan
executables like lake
and lean
.
As for mathlib, mathlib is a package, and current Lean package management unfortunately does not permit system wide package installs. You could have a preset package with mathlib already added to you have students open in VS Code. If you want students to create their own packages, you can have them use lake new <pkg> math
to automatically add mathlib as a dependency, but they will still need to manually do the lake exe cache get
dance to the get the oleans.
Miguel Marco (Jul 19 2023 at 12:46):
Thanks for the answer. Sadly, that doesn't work for me, since each user runs its own instance of vscode-server
(we need to do that, because we impose resource limitations at user level).
I could hack something copying the elan
toolchain and the 'lake-packages of a project to
usr/local and then linking them from each user directory (in the case of the
lake-packages` it is more tricky: i have a copy of the skeleton in each user dir, but the biggest subdirectories are symlinked). It works, but it is an ugly hack.
Sebastian Ullrich (Jul 19 2023 at 12:56):
Yes, you can put copies of Lean and mathlib4 somewhere and then add them to PATH
and LEAN_PATH
, respectively. I would say this is one of the few scenarios where touching LEAN_PATH
is warranted
Miguel Marco (Jul 19 2023 at 13:57):
what is exactly the role of LEAN_PATH
variable?
Sebastian Ullrich (Jul 19 2023 at 14:06):
It's the search path for import
. Try running lake env bash -c 'echo $LEAN_PATH'
in a Lake project
Miguel Marco (Jul 19 2023 at 14:08):
I see, if i have a global install, and have the proper PATH
and LEAN_PATH
variables, it should work without having anything specific in the user directory?
Sebastian Ullrich (Jul 19 2023 at 14:15):
Yes, exactly. Just make sure it's the same Lean version that produced the mathlib4 build files
Miguel Marco (Jul 19 2023 at 14:18):
thanks!
Miguel Marco (Jul 19 2023 at 15:17):
I tried that and I get an error message about manifest being outdated :man_shrugging:
Sebastian Ullrich (Jul 19 2023 at 15:20):
You should not use Lake at all in that case
Sebastian Ullrich (Jul 19 2023 at 15:21):
If you want users to develop a whole project with multiple files on top of mathlib4... then that's a problem with this approach
Miguel Marco (Jul 19 2023 at 15:24):
I see, well i will further investigate the approach of having a local project, but symlinking most of the directories to save space
Mac Malone (Jul 19 2023 at 15:56):
Miguel Marco said:
Thanks for the answer. Sadly, that doesn't work for me, since each user runs its own instance of
vscode-server
(we need to do that, because we impose resource limitations at user level).
This confuses me a bit. If users run their own instance of vscode-server
, why not have them run their own instance of elan
as well?
Miguel Marco (Jul 19 2023 at 20:38):
Mac said:
Miguel Marco said:
Thanks for the answer. Sadly, that doesn't work for me, since each user runs its own instance of
vscode-server
(we need to do that, because we impose resource limitations at user level).This confuses me a bit. If users run their own instance of
vscode-server
, why not have them run their own instance ofelan
as well?
Because that would imply having a copy of all the packages (about 4GB) per user. We have potentially hundreds of users, so we risk running out of disk space.
Kevin Buzzard (Jul 19 2023 at 20:46):
elan
is a very small program. It's mathlib that is huge.
Miguel Marco (Jul 19 2023 at 20:52):
yes, but if each user uses elan, it will install mathlib for each user.
Miguel Marco (Jul 19 2023 at 20:56):
the idea is to have averything set up so the students don't have to manage everything: they log in, and have a working environment to follow the course
Eric Wieser (Jul 19 2023 at 20:57):
Elan only manages lean, not mathlib
Eric Wieser (Jul 19 2023 at 20:57):
With only one lean version, I get
$ du -d0 -h ~/.elan
895M /home/gitpod/.elan
Eric Wieser (Jul 19 2023 at 20:58):
Which is big enough that a global install is probably not a waste of time
Eric Wieser (Jul 19 2023 at 21:00):
Regarding mathlib; can't you use require mathlib from /"your"/"global"/"mathlib"/"install"
in the lakefile?
Miguel Marco (Jul 19 2023 at 21:02):
Eric Wieser said:
Regarding mathlib; can't you use
require mathlib from /"your"/"global"/"mathlib"/"install"
in the lakefile?
Maybe... but don't know how to do it. I am kind of lost about what lake does.
Eric Wieser (Jul 19 2023 at 21:03):
When working on a local project depending on mathlib, lake is the thing downloading 3.6G of packages including mathlib
Miguel Marco (Jul 19 2023 at 21:08):
and how can i tell it to use a global install instead?
Eric Wieser (Jul 19 2023 at 21:57):
Eric Wieser said:
Regarding mathlib; can't you use
require mathlib from /"your"/"global"/"mathlib"/"install"
in the lakefile?
might do it
Miguel Marco (Jul 19 2023 at 22:27):
I get this error message:
warning: manifest out of date: source kind (git/path) of dependency mathlib changed, use `lake update` to update
info: mathlib: URL has changed; deleting ./lake-packages/mathlib and cloning again
error: permission denied (error code: 13)
file: ./lake-packages/mathlib/.github/workflows/bors.yml
Eric Wieser (Jul 19 2023 at 22:34):
Is this while also having your symlink hacks?
Miguel Marco (Jul 19 2023 at 22:36):
yes. Will try a fresh approach
Eric Wieser (Jul 19 2023 at 22:43):
I don't know if lake makes a copy of local paths or makes a symlink
Miguel Marco (Jul 19 2023 at 22:43):
WIth a fresh project, it seems to work, but it still downloads proofwidgets Cli Qq aesop and std
Is there a way to configure to use them from a system wide install too?
Eric Wieser (Jul 19 2023 at 22:44):
Did the above make a local copy of the mathlib
folder?
Miguel Marco (Jul 19 2023 at 22:45):
No, just the five packages I mentioned
Mario Carneiro (Jul 19 2023 at 22:48):
Eric Wieser said:
Regarding mathlib; can't you use
require mathlib from /"your"/"global"/"mathlib"/"install"
in the lakefile?
Note that FilePath
abuses the Div
operator to interpret the /
there. It's a binary operator so the initial /
is not syntactically legal
Miguel Marco (Jul 19 2023 at 22:50):
Oh, I just used a string with the full path:
require mathlib from "/usr/local/share/lean/lake-packages/mathlib"
Mario Carneiro (Jul 19 2023 at 22:51):
(the main purpose of using "foo" / "bar"
style is that it uses the appropriate directory separator for the OS; this is obviously not a problem if you know the system.)
Mario Carneiro (Jul 19 2023 at 22:52):
(not to mention that "/"
works as a directory separator on every supported system anyway)
Eric Wieser (Jul 19 2023 at 22:55):
I got that leading slash from a docstring
Mario Carneiro (Jul 19 2023 at 23:22):
double checked, it definitely doesn't work. which docstring?
Sebastian Ullrich (Jul 20 2023 at 07:01):
I think your best bet is to petition @Mac to allow Lake to inherit global LEAN_PATH
s, perhaps as an opt-in. At least from my rough understanding of Lake that should be easier and more robust to do than supporting this kind of global, prebuilt dependency in Lake itself.
Mac Malone (Jul 20 2023 at 07:04):
@Sebastian Ullrich Lake should already inherit the global LEAN_PATH
. If it does not, that is a bug.
Sebastian Ullrich (Jul 20 2023 at 07:06):
Oh! I briefly looked at the code yesterday and assumed it was by design to make the build more hermetic, but I didn't actually try
Mac Malone (Jul 20 2023 at 07:07):
Eric Wieser said:
I got that leading slash from a docstring
Oh, did your eyes fall on the /"path"/"dir"
part of the require
syntax docstring and extrapolate from there? If so, sorry! The non-git require syntax does not have a leading slash (as the docstring demonstrates at the top).
Sebastian Ullrich (Jul 20 2023 at 07:08):
@Miguel Marco so if it doesn't work with mathlib4 in LEAN_PATH
and not in the lakefile, please open an issue in the lean4 repo :)
Last updated: Dec 20 2023 at 11:08 UTC