# How do I know which enviroment I am in?

**URL:** <https://discourse.julialang.org/t/how-do-i-know-which-enviroment-i-am-in/57600>\
**Category:** New to Julia\
**Created:** [March 20, 2021, 1:40pm UTC](https://discourse.julialang.org/t/how-do-i-know-which-enviroment-i-am-in/57600 "2021-03-20T13:40:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [March 20, 2021, 1:40pm UTC](https://discourse.julialang.org/t/how-do-i-know-which-enviroment-i-am-in/57600/1 "2021-03-20T13:40:50Z")

</div>

Hi!

I’ve been trying to follow the steps here:

[https://pkgdocs.julialang.org/v1/environments/](https://pkgdocs.julialang.org/v1/environments/)

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:

![image](https://global.discourse-cdn.com/julialang/original/3X/a/6/a65dcfc030b0163f71a98b3e3b07ad3be8262c60.png)

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

---

<div class="post-metadata">

**Author:** ![josePereiro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josepereiro/32/17322_2.png) [@josePereiro](https://discourse.julialang.org/u/josePereiro)\
**Post date:** [March 20, 2021, 1:53pm UTC](https://discourse.julialang.org/t/how-do-i-know-which-enviroment-i-am-in/57600/2 "2021-03-20T13:53:46Z")

</div>

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
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

```

---

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [March 20, 2021, 1:56pm UTC](https://discourse.julialang.org/t/how-do-i-know-which-enviroment-i-am-in/57600/3 "2021-03-20T13:56:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![josePereiro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josepereiro/32/17322_2.png) [@josePereiro](https://discourse.julialang.org/u/josePereiro)\
**Post date:** [March 20, 2021, 1:58pm UTC](https://discourse.julialang.org/t/how-do-i-know-which-enviroment-i-am-in/57600/4 "2021-03-20T13:58:07Z")

</div>

I think that’s correct

---

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [March 20, 2021, 2:08pm UTC](https://discourse.julialang.org/t/how-do-i-know-which-enviroment-i-am-in/57600/5 "2021-03-20T14:08:55Z")

</div>

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

Kind regards

---

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [March 20, 2021, 2:29pm UTC](https://discourse.julialang.org/t/how-do-i-know-which-enviroment-i-am-in/57600/6 "2021-03-20T14:29:59Z")

</div>

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.
