How do I know which enviroment I am in?


I’ve been trying to follow the steps here:

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?

Kind regards

1 Like

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()
# 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()

Okay, so I suppose, that I should always use “Base.active_project()”, since it will inform me in which enviroment any Pkg install will be saved in?

Kind regards

I think that’s correct

Okay nice, will mark your first answer is solution, thanks!

Kind regards


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.