# Shared environments

**URL:** <https://discourse.julialang.org/t/shared-environments/35999>\
**Category:** General Usage\
**Tags:** question, pkg, shared-environments\
**Created:** [March 15, 2020, 2:01am UTC](https://discourse.julialang.org/t/shared-environments/35999 "2020-03-15T02:01:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![cstjean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cstjean/32/1444_2.png) [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Post date:** [March 15, 2020, 2:01am UTC](https://discourse.julialang.org/t/shared-environments/35999/1 "2020-03-15T02:01:23Z")

</div>

I recently [learned](https://discourse.julialang.org/t/why-start-domain-specific-scientific-projects-as-packages/34752/11) about “shared environments”, aka the default `v1.3` environment. It’s quite a revelation, but I don’t understand how it works. Suppose I have

- Package A which depends on B@v1.0.0, and is compatible with no other version of B. A is in the shared environment’s Project.toml.
- Environment E, which has package C in its Project.toml. C depends on B@v2.0.0 (compatible with no other version).

When I am in E and I `using A`, which version of B is loaded?

---

<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 15, 2020, 12:22pm UTC](https://discourse.julialang.org/t/shared-environments/35999/2 "2020-03-15T12:22:49Z")

</div>

I think you will find this useful:

> [@Handling various types of dependencies](https://discourse.julialang.org/t/handling-various-types-of-dependencies/27850/17):
>
> I think you can find an answer in this comparison of Julia’s Pkg to Go’s packaging system: Go is treating packages with different major versions as essentially different packages. So the above scenario would have “worked” in the sense that PkgC would load PkgB 2.0 instead of PkgB 1.9.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [March 15, 2020, 12:34pm UTC](https://discourse.julialang.org/t/shared-environments/35999/3 "2020-03-15T12:34:02Z")

</div>

Compat has nothing to do with what is being loaded. Compat is used by the resolver when the Manifest is created but nothing in the code that loads packages looks at it.

Given a package to be loaded, each Manifest in `Base.load_path()` is looked at and the version that is first found is loaded. So here, you want to load `B` and `B` exists in the manifest file of project `E` so whatever version is in there will be loaded.

---

<div class="post-metadata">

**Author:** ![cstjean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cstjean/32/1444_2.png) [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Post date:** [March 15, 2020, 12:49pm UTC](https://discourse.julialang.org/t/shared-environments/35999/4 "2020-03-15T12:49:09Z")

</div>

`E` requires `C`, which is only compatible with `B@v2.0.0`, so that would be loaded? Then how can `using A` succeed, if it’s only compatible with `B@v1.0.0`?

In other words, I always assumed that you can’t combine/stack environments, because the manifest of environment 1 and environment 2 can be incompatible. You’d have to resolve the combined Project.toml together, which doesn’t seem to be done?

Or are two different versions of A loaded simultaneously?

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [March 15, 2020, 12:51pm UTC](https://discourse.julialang.org/t/shared-environments/35999/5 "2020-03-15T12:51:20Z")

</div>

> [@cstjean](#):
>
> `E` requires `C` , which is only compatible with `B@v2.0.0` , so that would be loaded? Then how can `using A` succeed, if it’s only compatible with `B@v1.0.0` ?

It might fail.

> [@cstjean](#):
>
> Or are two different versions of A loaded simultaneously?

No, only one version of each package is ever loaded in a Julia session.

---

<div class="post-metadata">

**Author:** ![cstjean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cstjean/32/1444_2.png) [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Post date:** [March 15, 2020, 12:55pm UTC](https://discourse.julialang.org/t/shared-environments/35999/6 "2020-03-15T12:55:33Z")

</div>

> [@kristoffer.carlsson](#):
>
> It might fail.

Ok, so if `A` is currently at `v1.3.0` in the shared environment (unpinned), incompatible with the `B` version in the `E` manifest, does `using A` fail right away, or does julia look for another version of `A` compatible with the `B` from `E`?

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [March 15, 2020, 12:58pm UTC](https://discourse.julialang.org/t/shared-environments/35999/7 "2020-03-15T12:58:06Z")

</div>

> [@cstjean](#):
>
> does `using A` fail right away,

With fail I just meant that package `A` might not work correctly because an incompatible version of `B` is loaded.

Again, compat information does not influence what package is being loaded at all.

---

<div class="post-metadata">

**Author:** ![cstjean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cstjean/32/1444_2.png) [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Post date:** [March 15, 2020, 1:17pm UTC](https://discourse.julialang.org/t/shared-environments/35999/8 "2020-03-15T13:17:36Z")

</div>

Oh, makes sense! Sorry for being obtuse above, and thank you for the patient answers.
