Zulip Chat Archive
Stream: mathlib4
Topic: Why does it always say "unknown package 'Mathlib'"? Thanks.
Lewis (Jun 16 2024 at 04:22):
Why does it always say "unknown package 'Mathlib'"? Thanks.
Bolton Bailey (Jun 16 2024 at 05:10):
Possibly you are working in a Lean project that does not list mathlib as a dependency. If you provide more details about what situation you are in someone is more likely to be able to help.
Utensil Song (Jun 16 2024 at 05:10):
Likely the same issue.
Utensil Song (Jun 16 2024 at 05:16):
I guess you are seeing this from the Lean Infoview. It's my knee-jerk reaction to fix this in command line so I forgot the details. You might just need a lake -R update mathlib
and lake build
.
Utensil Song (Jun 16 2024 at 05:19):
@Marc Huisinga might have more clues to fix it using only the VSCode extension if you provide more details.
Particularly, how did you create/open the Lean project? The result could be different for opening it from different directory.
Kevin Buzzard (Jun 16 2024 at 08:19):
Often the answer to this question is the far more mundane "I opened a random file called test.lean
without ever setting up a lean project"
Lewis (Jun 16 2024 at 10:41):
Thank you for your reply. How to fix the error:
"error: [root]: no configuration file with a supported extension: ././lakefile.lean ././lakefile.toml"
when running "lake update"? Thanks a lot!
Utensil Song said:
Marc Huisinga might have more clues to fix it using only the VSCode extension if you provide more details.
Particularly, how did you create/open the Lean project? The result could be different for opening it from different directory.
Lewis (Jun 16 2024 at 10:41):
Kevin Buzzard said:
Often the answer to this question is the far more mundane "I opened a random file called
test.lean
without ever setting up a lean project"
Thank you for your reply. How to fix the error:
"error: [root]: no configuration file with a supported extension: ././lakefile.lean ././lakefile.toml"
when running "lake update"? Thanks a lot!
Lewis (Jun 16 2024 at 10:49):
Now running lake update
does not encounter the error, but why does it still say "unknown package 'Mathlib'"? Thanks!
Kim Morrison (Jun 16 2024 at 11:37):
@Lewis, you're going to need to explain how you created your project, which instructions you followed, etc.
Kim Morrison (Jun 16 2024 at 11:37):
Posting your lakefile.lean
(or lakefile.toml
, depending on which you have) might also be helpful.
Kevin Buzzard (Jun 16 2024 at 13:25):
Again I'll conjecture that the user has no project at all and is just running lean on a standalone file, which doesn't work
Kevin Buzzard (Jun 16 2024 at 13:30):
Can the OP please send a screenshot of VS Code showing the error and with the file explorer open?
Lewis (Jun 16 2024 at 13:42):
Kevin Buzzard said:
Again I'll conjecture that the user has no project at all and is just running lean on a standalone file, which doesn't work
Here is the screenshot:
https://docsend.com/view/x4ijgz9bfhzrv8mt
Could you please help me make Mathlib importing work? Thanks a lot!
Lewis (Jun 16 2024 at 13:44):
Kim Morrison said:
Lewis, you're going to need to explain how you created your project, which instructions you followed, etc.
Here is the content of the file:
import Lake
open Lake DSL
package mil where
leanOptions := #[
⟨pp.unicode.fun, true⟩, -- pretty-prints
fun a ↦ b
⟨
autoImplicit, false⟩,
⟨`relaxedAutoImplicit, false⟩]
@[default_target]
lean_lib MIL where
require mathlib from git "https://github.com/leanprover-community/mathlib4"@"master"
Could you please help me make Mathlib importing work? Thanks a lot!
Lewis (Jun 16 2024 at 13:50):
Kim Morrison said:
Lewis, you're going to need to explain how you created your project, which instructions you followed, etc.
Here is the content of the file:
import Lake
open Lake DSL
package mil where
leanOptions := #[
⟨pp.unicode.fun, true⟩, -- pretty-prints
fun a ↦ b ⟨
autoImplicit, false⟩,
⟨`relaxedAutoImplicit, false⟩]
@[default_target]
lean_lib MIL where
require mathlib from git "https://github.com/leanprover-community/mathlib4"@"master"
Could you please help me make Mathlib importing work? Thanks a lot!
Patrick Massot (Jun 16 2024 at 13:52):
The project seems to be MIL so there is definitely no issue in the Lean file. The issue has to be that you don’t open the right folder in VSCode (or don’t open a folder at all but open a file).
Patrick Massot (Jun 16 2024 at 13:52):
We need a screenshot where we see the VSCode file explorer open.
Utensil Song (Jun 16 2024 at 13:52):
From the screenshot, you have only open a standalone file te.lean
on desktop, with no project structure, that's causing the error. You need to check out the project structure of https://github.com/leanprover-community/mathematics_in_lean and organize the files in a similar way.
Patrick Massot (Jun 16 2024 at 13:53):
And no need to use an external site to post screenshot, pasting an image here is fine.
Patrick Massot (Jun 16 2024 at 13:55):
Utensil, you make it sound more complicated than it needs to be.
Patrick Massot (Jun 16 2024 at 13:55):
Lewis, you simply need to tell VSCode to open the folder containing the lakefile.
Marc Huisinga (Jun 16 2024 at 14:08):
Patrick Massot said:
The project seems to be MIL so there is definitely no issue in the Lean file. The issue has to be that you don’t open the right folder in VSCode (or don’t open a folder at all but open a file).
This is not necessary anymore. The problem is very likely what Kevin and Utensil suggested, namely that there is a file te.lean
that is in a folder Desktop/my_project
above the mathematics_in_lean
folder that contains the Lean project, whereas my_project
is probably not a Lean project itself. For MiL in particular it may obviously still make sense to open the right folder, though, given that the explorer view is more restrictive.
Utensil Song said:
Marc Huisinga might have more clues to fix it using only the VSCode extension if you provide more details.
Particularly, how did you create/open the Lean project? The result could be different for opening it from different directory.
The right first step here is to ask users to run the Troubleshooting: Show Setup Information
command and then paste the output on Zulip. It will tell you whether Lean is running in a project or in a standalone file.
Last updated: May 02 2025 at 03:31 UTC