# Question regarding Pkg environments

**URL:** <https://discourse.julialang.org/t/question-regarding-pkg-environments/36249>\
**Category:** General Usage\
**Created:** [March 20, 2020, 9:48am UTC](https://discourse.julialang.org/t/question-regarding-pkg-environments/36249 "2020-03-20T09:48:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![skarppinen](https://avatars.discourse-cdn.com/v4/letter/s/67e7ee/32.png) [@skarppinen](https://discourse.julialang.org/u/skarppinen)\
**Post date:** [March 20, 2020, 9:48am UTC](https://discourse.julialang.org/t/question-regarding-pkg-environments/36249/1 "2020-03-20T09:48:25Z")

</div>

Hello.  
I am confused about using Pkg environments.

Suppose I create a new directory on my system called “NewProject”.  
Then I change my directory to this new folder, launch Julia, hit `]` to launch Pkg and type `activate .`.  
Now, Pkg tells me that the active environment is “NewProject” by displaying: `(NewProject) pkg>`.

With my new environment active, if I then run `using X` for some package `X` that is installed in the “global” default environment (v1.3), Julia loads the package just fine, even though I have not added it to the active environment (NewProject) with `add X` in Pkg. What I would like is for this new environment to be completely separate from the global environment, and for Julia to complain that the package that I am trying to load does not exist (in the active environment NewProject). Is this the way Pkg is supposed to work, or am I doing something wrong? Can I somehow configure Pkg to only see the packages that have been added to the active environment?

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [March 20, 2020, 10:59am UTC](https://discourse.julialang.org/t/question-regarding-pkg-environments/36249/2 "2020-03-20T10:59:13Z")

</div>

You may be looking for something like

```julia
empty!(LOAD_PATH)
push!(LOAD_PATH, "@")

```

See [https://docs.julialang.org/en/latest/manual/code-loading/#Environment-stacks-1](https://docs.julialang.org/en/latest/manual/code-loading/#Environment-stacks-1), and `?LOAD_PATH`.

---

<div class="post-metadata">

**Author:** ![skarppinen](https://avatars.discourse-cdn.com/v4/letter/s/67e7ee/32.png) [@skarppinen](https://discourse.julialang.org/u/skarppinen)\
**Post date:** [March 20, 2020, 11:05am UTC](https://discourse.julialang.org/t/question-regarding-pkg-environments/36249/3 "2020-03-20T11:05:22Z")

</div>

Thank you very much.  
This is exactly what I meant. Too bad there is no indication of this in the Pkg documentation.

---

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [March 20, 2020, 11:24am UTC](https://discourse.julialang.org/t/question-regarding-pkg-environments/36249/4 "2020-03-20T11:24:12Z")

</div>

Note also that `Pkg.test` will complain if dependencies are missing from `Project.toml` because tests run in a “clean” environment.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [March 20, 2020, 11:41am UTC](https://discourse.julialang.org/t/question-regarding-pkg-environments/36249/5 "2020-03-20T11:41:35Z")

</div>

> [@skarppinen](#):
>
> Too bad there is no indication of this in the Pkg documentation.

I think there is, [8. Glossary · Pkg.jl](https://julialang.github.io/Pkg.jl/dev/glossary/) has

> **Environment:** the combination of the top-level name map provided by a project file combined with the dependency graph and map from packages to their entry points provided by a manifest file. For more detail see the manual section on code loading.

---

<div class="post-metadata">

**Author:** ![skarppinen](https://avatars.discourse-cdn.com/v4/letter/s/67e7ee/32.png) [@skarppinen](https://discourse.julialang.org/u/skarppinen)\
**Post date:** [March 20, 2020, 11:56am UTC](https://discourse.julialang.org/t/question-regarding-pkg-environments/36249/6 "2020-03-20T11:56:20Z")

</div>

Yes, that defines what an environment means, but does not explain how they work in practice.

In my opinion, something about this could be written here in the section that is labeled “Working with Environments”:  
[https://julialang.github.io/Pkg.jl/v1/environments/](https://julialang.github.io/Pkg.jl/v1/environments/)

Currently, there is a line that says “This new environment is completely separate from the one we used earlier.” after showing how an environment can be activated. Without the modifications to LOAD\_PATH you suggested, I find this to be false.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [March 20, 2020, 12:37pm UTC](https://discourse.julialang.org/t/question-regarding-pkg-environments/36249/7 "2020-03-20T12:37:07Z")

</div>

> [@skarppinen](#):
>
> Yes, that defines what an environment means, but does not explain how they work in practice.

I am not sure if you missed this part:

> For more detail see the manual section on code loading.

which is exactly the section I linked above. So there is _some indication_ of the relevant docs in the Pkg docs. Just not the details. But I am not sure they belong there.

Perhaps you could make a PR to the tutorial part of the Pkg docs, but keep in mind that the use case in this topic is not the common one.
