Zulip Chat Archive

Stream: new members

Topic: Struggling to run Lean 3 and Lean 4 side by side in vscode


Richard Evans (Apr 25 2022 at 17:15):

Hi, I installed vscode with extensions for Lean 3 and Lean 4. The Lean 4 extension works nicely, but I cannot get the Lean 3 extension to work.

It says:

> bash -c 'curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y --default-toolchain leanprover-community/lean:3.20.0 || echo && read -n 1 -s -r -p "Install failed, press ENTER to continue..."' && exit
info: downloading installer
info: updating existing elan installation

Install failed, press ENTER to continue...

Does anybody know whether/how it is possible to have both versions of Lean running within VSCode? thanks in advance -

Richard Evans (Apr 25 2022 at 17:25):

Here is a screenshot of what happens when I open up a Lean3 file in vscode:

lean-error.png

(If I load a Lean4 file, everything works just fine).

Richard Evans (Apr 25 2022 at 17:29):

I have both lean and lean4 extensions installed.

Here is a screenshot of a Lean4 file working just fine:
lean-working.png

Arthur Paulino (Apr 25 2022 at 17:33):

Someone else might have a better solution, but I cherry pick the workspaces for which the extensions will be triggered by hand. For Lean 3, it's allowed to trigger on mathlib, only... And I keep the Lean 4 extension off there. And for everything else I let the Lean 4 extension trigger automatically and have the Lean 3 extension off by default (I work with Lean 4 mostly)

Chris B (Apr 25 2022 at 17:40):

It's definitely possible. What are your version numbers for vscode and the lean4 extension?

Richard Evans (Apr 25 2022 at 18:20):

For lean4, it is v0.0.71. For lean, it is v0.16.46. For VSCode, it is 1.66.2. (Running on Mac).

Chris B (Apr 25 2022 at 20:13):

That's the same setup I'm using; what's the output of elan toolchain list? When I have issues with elan, I usually just uninstall/reinstall (elan self uninstall).

Richard Evans (Apr 26 2022 at 05:10):

I get:

> elan toolchain list
leanprover-community/lean:3.20.0
leanprover/lean4:nightly (default)

and:

> elan show
installed toolchains
--------------------

leanprover-community/lean:3.20.0
leanprover/lean4:nightly (default)

active toolchain
----------------

leanprover/lean4:nightly (default)
Lean (version 4.0.0-nightly-2022-03-28, commit 4e008cf8b701, Release)

Is it significant that lean3 is not in the list of active toolchains?

Mauricio Collares (Apr 26 2022 at 07:12):

What happens if you execute elan show inside the logical_verification_2020 folder?

Richard Evans (Apr 26 2022 at 07:57):

Inside the logical_verification_2020 folder, I get:

> elan show
installed toolchains
--------------------

leanprover-community/lean:3.20.0
leanprover/lean4:nightly (default)

active toolchain
----------------

leanprover-community/lean:3.20.0 (overridden by '/Users/richardevans/Documents/research/work/projects/lean/logical_verification_2020/leanpkg.toml')
(error reading lean version)

Mauricio Collares (Apr 26 2022 at 08:07):

"error reading lean version" is suspicious. What is the error you get when running lean --version inside the LV2020 folder?

Richard Evans (Apr 26 2022 at 08:23):

> lean --version
dyld[2506]: Library not loaded: /usr/local/opt/gmp/lib/libgmp.10.dylib
  Referenced from: /Users/richardevans/.elan/toolchains/leanprover-community--lean---3.20.0/bin/lean
  Reason: tried: '/Users/richardevans/.elan/toolchains/leanprover-community--lean---3.20.0/lib/libgmp.10.dylib' (no such file), '/usr/local/opt/gmp/lib/libgmp.10.dylib' (no such file), '/usr/local/lib/libgmp.10.dylib' (no such file), '/usr/lib/libgmp.10.dylib' (no such file)
Abort trap: 6

Mauricio Collares (Apr 26 2022 at 08:30):

Are you using a M1 Mac? If so, this part of the elan readme might be useful:

Lean 4 has native macOS/aarch64 releases (nightly only so far) that you can install as above by choosing the leanprover/lean4:nightly toolchain. For Lean 3, you need to run the installer under Rosetta (install using softwareupdate --install-rosetta if you haven't already done so) because there are no M1 releases for it right now:

curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | arch -x86_64 sh

Richard Evans (Apr 26 2022 at 08:33):

Thanks Mauricio. I will try that.

Richard Evans (Apr 26 2022 at 08:48):

Oh no hang on. It isn't an M1 mac - it is an intel.

Mauricio Collares (Apr 26 2022 at 08:51):

Ah, I see! The instructions on the lean-community website could be useful then: https://leanprover-community.github.io/install/macos.html#intel-macs. The script installs elan via brew, which probably installs dependencies such as gmp automatically.

Mauricio Collares (Apr 26 2022 at 08:52):

I am not a Mac user, so I'll have to let more experienced people help you if this fails

Richard Evans (Apr 26 2022 at 09:49):

Thanks! I will try this...

Richard Evans (Apr 26 2022 at 15:41):

Thanks for all your help everyone. It is working now :)


Last updated: Dec 20 2023 at 11:08 UTC