# How can I make a package run in its own environment

**URL:** https://discourse.julialang.org/t/how-can-i-make-a-package-run-in-its-own-environment/26601
**Category:** General Usage
**Tags:** package, package-manager
**Created:** [July 21, 2019, 7:43am UTC](https://discourse.julialang.org/t/how-can-i-make-a-package-run-in-its-own-environment/26601 "2019-07-21T07:43:06Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Chong\_Wang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chong_wang/32/20307_2.png) [@Chong\_Wang](https://discourse.julialang.org/u/Chong_Wang)
#### Post date: [July 21, 2019, 7:43am UTC](https://discourse.julialang.org/t/how-can-i-make-a-package-run-in-its-own-environment/26601/1 "2019-07-21T07:43:06Z")

</div>

If I create a package `Foo` depending on `Bar@0.1.0`, and the default environment (say, `v1.1`) has `Bar@0.2.0`, how can I use the package `Foo` in the default environment?

Here’s what I did:

In the environment `Foo`, I `]add Bar@0.1.0`. Clearly this creates a manifest.toml file with `Bar@0.1.0`. Then I switch back to the default environment `v1.1` and then `using Foo`, `Foo` wouldn’t precompile due to compatibility issues (`v0.1.0` vs `v0.2.0`).

My expectation is that `Foo` will run in its own environment described by its manifest.toml no matter what is the environment where `Foo` is used. However, this does not seem to be the case in my practice. Then, how can I simultaneously use two packages that have contradictory dependency requirements?

---

<div class="post-metadata">

### Author: ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)
#### Post date: [July 21, 2019, 7:58am UTC](https://discourse.julialang.org/t/how-can-i-make-a-package-run-in-its-own-environment/26601/2 "2019-07-21T07:58:49Z")

</div>

Hello @Chong_Wang Is this documentation useful  
[4. Working with Environments · Pkg.jl](https://julialang.github.io/Pkg.jl/v1/environments/)

---

<div class="post-metadata">

### Author: ![Chong\_Wang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chong_wang/32/20307_2.png) [@Chong\_Wang](https://discourse.julialang.org/u/Chong_Wang)
#### Post date: [July 21, 2019, 8:04am UTC](https://discourse.julialang.org/t/how-can-i-make-a-package-run-in-its-own-environment/26601/3 "2019-07-21T08:04:54Z")

</div>

I read the documentation before asking questions here.

---

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [July 21, 2019, 8:06am UTC](https://discourse.julialang.org/t/how-can-i-make-a-package-run-in-its-own-environment/26601/4 "2019-07-21T08:06:12Z")

</div>

You can’t. If you require a specific version of your dependencies you should include that information in the `[compat] ` section in `Project.toml`, see [6. Compatibility · Pkg.jl](https://julialang.github.io/Pkg.jl/v1/compatibility/)

---

<div class="post-metadata">

### Author: ![Chong\_Wang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chong_wang/32/20307_2.png) [@Chong\_Wang](https://discourse.julialang.org/u/Chong_Wang)
#### Post date: [July 21, 2019, 8:08am UTC](https://discourse.julialang.org/t/how-can-i-make-a-package-run-in-its-own-environment/26601/5 "2019-07-21T08:08:30Z")

</div>

So if two packages `Foo1` and `Foo2` have different requirements (say `Bar@0.1.0` and `Bar@0.2.0`), I cannot use them at the same time?

---

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [July 21, 2019, 8:13am UTC](https://discourse.julialang.org/t/how-can-i-make-a-package-run-in-its-own-environment/26601/6 "2019-07-21T08:13:53Z")

</div>

Correct.
