# How does environment stacking work?

**URL:** <https://discourse.julialang.org/t/how-does-environment-stacking-work/64635>\
**Category:** New to Julia\
**Tags:** question, environment\
**Created:** [July 14, 2021, 1:48pm UTC](https://discourse.julialang.org/t/how-does-environment-stacking-work/64635 "2021-07-14T13:48:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![orome](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/orome/32/26965_2.png) [@orome](https://discourse.julialang.org/u/orome)\
**Post date:** [July 14, 2021, 1:48pm UTC](https://discourse.julialang.org/t/how-does-environment-stacking-work/64635/1 "2021-07-14T13:48:39Z")

</div>

[\> Julia environments are stacked.](https://discourse.julialang.org/t/why-not-always-use-revise/64589/6)

So just to be sure I understand this: If I `activate X` then I can `using` anything that’s `add`ed or `dev`ed in not just `X` but also anything that’s in the load path (so by default, anything up the directory hierarchy, for example)?

If that’s right then what happens when I `julia --project=@.` or `julia --project=.`

---

<div class="post-metadata">

**Author:** ![fbanning](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fbanning/32/14972_2.png) [@fbanning](https://discourse.julialang.org/u/fbanning)\
**Post date:** [July 14, 2021, 1:55pm UTC](https://discourse.julialang.org/t/how-does-environment-stacking-work/64635/2 "2021-07-14T13:55:22Z")

</div>

Not sure if this answers your question:

```julia
julia> Base.LOAD_PATH
3-element Vector{String}:
 "@"
 "@v#.#"
 "@stdlib"

```

---

<div class="post-metadata">

**Author:** ![tsela](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tsela/32/52174_2.png) [@tsela](https://discourse.julialang.org/u/tsela)\
**Post date:** [July 14, 2021, 3:26pm UTC](https://discourse.julialang.org/t/how-does-environment-stacking-work/64635/3 "2021-07-14T15:26:14Z")

</div>

As @fbanning showed, the standard LOAD\_PATH has three values. `@stdlib` is the standard library, `@v#.#` is the base environment of your Julia version (`v1.6` for Julia 1.6 for instance, where `add`ed packages live that weren’t added in an activated environment) and `@` refers to the currently activated environment if there is any. So when you call `import` or `using`, Julia goes through those sources in order to find the package to load, starting with a possibly activated local environment, then checking the base environment, and finally checking the standard library (unless you manually modify LOAD\_PATH, making it possible to add even more places to check).

When you start Julia as you wrote, you simply bind the `@` entry to the activated environment. Julia will still search the base environment and the standard lib if you try `using` something that’s not in that environment.

It’s pretty simple when you think about it.
