I am testing from the REPL. Basically I follow the steps and I see that I make a new project, which puts Pkg in the “MyProject” enviroment:
But when I backspace out, this “MyProject” goes away infront of the Julia part. How can I be sure that the next packages I install are actually installed in this enviroment?
You can use Base.active_project(). It will return the address of the Project.toml used for the Pkg. Another similar method exist, Base.currect_project(), but the “current” there refers to the first Project.toml you find searching up from your current location pwd(), not the one used by the Pkg.
They can match or not.
Example: Opening a julia section in my home directory.
julia> # Press ]
(@v1.5) pkg> # At first, my global envitoment is activated
julia> Base.current_project()
# Returns nothing (or empty string, I don't know)
# This is because in my home folder (and parents), no Project.toml exist.
julia> Base.active_project()
"/Users/Pereiro/.julia/environments/v1.5/Project.toml"
# This time, the active global Project.toml is returned
julia> cd("/Users/Pereiro/.julia/environments/v1.5")
# If I navigate to its container folder now both methods returns the same
julia> Base.current_project() == Base.active_project()
true
For interactive use I don’t think you need to do anything: if pkg> says you are in MyProject, that’s where packages will be installed. For a programmatic check however you need @josePereiro’s solution.