6
$\begingroup$

I followed Lean documentation to install Lean 4 on my Ubuntu Linux (20.04 LTS) using the elan option described there, and updated it to Lean4 m3 using:

elan self update
elan default leanprover/lean4:stable
elan update

I noticed that my Lean folder ~/.elan is now taking a lot of space (1.5G). Most space is taken by sub-directory is ~/.elan/toolchains:

539M    ./leanprover--lean4---nightly
535M    ./leanprover--lean4---stable
332M    ./leanprover-lean4-stable
31M     ./stable

It seems that elan installed all three branches of Lean (two of the four are for lean4-stable):

$ elan update
info: syncing channel updates for 'stable'
info: latest update on stable, lean version v3.39.2
info: syncing channel updates for 'nightly'
info: latest update on nightly, lean version nightly-2022-02-20
info: syncing channel updates for 'stable'
info: latest update on stable, lean version v4.0.0-m3
info: checking for self-updates

                    stable unchanged - Lean (version 3.39.2, commit 402f41cdedbd, Release)
  leanprover/lean4:nightly unchanged - Lean (version 4.0.0-nightly-2022-02-20, commit 7a13eaea8da4, Release)
   leanprover/lean4:stable unchanged - Lean (version 4.0.0, commit d2dcff1f9a20, Release)

But I only need one branch - leanprover/lean4:stable.

My questions are:

How can I make sure that elan only installs and updates one branch of Lean4?

What is the proper way to remove an unused branch? (elan does not seems to have a remove command)

$\endgroup$
4
  • $\begingroup$ Thanks. I tried both elan target and elan remove, and elan says it's invalid command. $\endgroup$
    – tinlyx
    Feb 20, 2022 at 23:19
  • $\begingroup$ The correct command is elan toolchain uninstall, like in rustup $\endgroup$ Feb 21, 2022 at 8:34
  • $\begingroup$ @SebastianUllrich Indeed, if you post it as an answer. I'll accept it. $\endgroup$
    – tinlyx
    Feb 21, 2022 at 15:19
  • $\begingroup$ is there a way to uninstall theelan? is that recommended? I was trying to re-ininstall all of lean form scratch. $\endgroup$ Feb 23 at 20:42

1 Answer 1

4
$\begingroup$

As suggested by @SebastianUllrich in the comments:

The command for removing a toolchain is elan toolchain uninstall branch_name, like in rustup. (rustup command examples)

For example, the following removes the stable branch (be sure to replace it with the name of the branch you want to remove!):

$ elan toolchain uninstall stable
info: uninstalling toolchain 'stable'
info: toolchain 'stable' uninstalled

-- my original answer --:

I just tried the hard way by deleting the directories of the the unused in ~/.elan/toolchains (after trial and errors) with:

rm -rf ./leanprover-lean4-stable ./leanprover--lean4---nightly

and then did elan update again. It seems that elan can recognize and handle the changes, and it only shows the remaining branches after the update:

$ elan update
info: syncing channel updates for 'stable'
info: latest update on stable, lean version v3.39.2
info: syncing channel updates for 'stable'
info: latest update on stable, lean version v4.0.0-m3
info: checking for self-updates

                   stable unchanged - Lean (version 3.39.2, commit 402f41cdedbd, Release)
  leanprover/lean4:stable unchanged - Lean (version 4.0.0, commit d2dcff1f9a20, Release)

The other branches do not show up again.

$\endgroup$
1
  • $\begingroup$ is there a way to uninstall theelan? is that recommended? I was trying to re-ininstall all of lean form scratch. $\endgroup$ Feb 23 at 20:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.