I want to create a lean project inside another folder besides the $HOME
folder. So I was going through the official Creating a Lean project instructions on how to create a Lean Project, but it only works (i.e., the import to mathlib) only works if I do the instruction on $HOME.
So for example the instructions say:
Go to a folder where you want to create a project in a subfolder my_project, and type lake +leanprover/lean4:nightly-2023-02-04 new my_project math.
but when "go to a folder" is anything but the root it doesn't work.
I wrote a bash file for what the instructions say,
one were it works (the one at $HOME) and
one that doesn't work (when I try to create the lean project not at $HOME):
Project Creation works when doing instructions at $HOME
# -- Go to a folder where you want to create a project in a subfolder my_project, and type lake +leanprover/lean4:nightly-2023-02-04 new my_project math.
cd $HOME
lake +leanprover/lean4:nightly-2023-02-04 new my_project math
# if you get an error message saying lake is an unknown command and you have not logged in since you installed Lean, then you may need to first type
# source ~/.profile or source ~/.bash_profile
# - Go inside the my_project folder and type lake update, then lake exe cache get and then mkdir MyProject.
cd my_project
lake update
lake exe cache get
mkdir MyProject
# Your Lean code should now be put inside files with extension .lean living in my_project/MyProject/ or a subfolder thereof.
cd MyProject
touch Test.lean
echo 'import Mathlib.Topology.Basic\n\n#check TopologicalSpace' > Test.lean
Project Creation fails anywhere else e.g., inside a $HOME/entire_project_root
mkdir $HOME/entire_project_root
# -- Go to a folder where you want to create a project in a subfolder my_project, and type lake +leanprover/lean4:nightly-2023-02-04 new my_project math.
cd $HOME/entire_project_root
lake +leanprover/lean4:nightly-2023-02-04 new my_project math
# if you get an error message saying lake is an unknown command and you have not logged in since you installed Lean, then you may need to first type
# source ~/.profile or source ~/.bash_profile
# - Go inside the my_project folder and type lake update, then lake exe cache get and then mkdir MyProject.
cd my_project
lake update
lake exe cache get
mkdir MyProject
# Your Lean code should now be put inside files with extension .lean living in my_project/MyProject/ or a subfolder thereof.
cd MyProject
touch Test.lean
echo 'import Mathlib.Topology.Basic\n\n#check TopologicalSpace' > Test.lean
Is this the expected behaviour?
The error message is:
Test.lean:1:0
unknown package 'Mathlib'
Comment on version 2023-02-04
@FrançoisG.Dorais quoting the official instructions/documentation:
Do not worry about the date in the previous command, it ensures you will use a sufficiently recent version of lake but has no impact on the version of lean your project will use
https://leanprover-community.github.io/install/project.html#creating-a-lean-project so idk, I'm just reading them and following what the lean maintainers tell me to do. I agree with you at first glance.
my_project
not inMyProject
. $\endgroup$Do not worry about the date in the previous command, it ensures you will use a sufficiently recent version of lake but has no impact on the version of lean your project will use
leanprover-community.github.io/install/… so idk, I'm just reading them and following what the lean maintainers tell me to do. I agree with you at first glance. $\endgroup$$HOME
in the example that actually works) where the lean project will be calledmy_project
in my example. That folder will have a bunch of lean files like.lake
,lakefile.lean
,lean-toolchain
etc. Then insidemy_folder
there will be the folder where the actual lean src code will be. That is the third folder calledMyProject
. This is the structure if I understand the official instructions correctly $\endgroup$