# Nested environments in package

**URL:** <https://discourse.julialang.org/t/nested-environments-in-package/33157>\
**Category:** General Usage\
**Created:** [January 9, 2020, 1:36pm UTC](https://discourse.julialang.org/t/nested-environments-in-package/33157 "2020-01-09T13:36:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![racinmat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/racinmat/32/11715_2.png) [@racinmat](https://discourse.julialang.org/u/racinmat)\
**Post date:** [January 9, 2020, 1:36pm UTC](https://discourse.julialang.org/t/nested-environments-in-package/33157/1 "2020-01-09T13:36:57Z")

</div>

Hi,  
I have a package with the usual structure, but I also have examples here, because I believe runnable code is more useful than snippets in md.  
So the structure is something like

```julia
- examples/
- src/
- test/
  - Project.toml
- Project.toml

```

the `Project.toml` is there accoring to the Pkg docs: [5. Creating Packages · Pkg.jl](https://julialang.github.io/Pkg.jl/v1/creating-packages/#Test-specific-dependencies-in-Julia-1.2-and-above-1)  
and I really like the notion of nested directories where test has some additional dependencies next to the project itself.

And my question is: how to achieve the same thing with examples?  
So I would have a Project.toml in examples with some additional dependencies needed to run them, but not needed in the package itself.  
Is there a way to do it?  
So far I didn’t figure anything out, and having a separate repo for examples which is just few (2-3 scripts) seems like an overkil, but I’m open to any solution that would let me specify the deps for examples without flodding the library itself with garbage.

---

<div class="post-metadata">

**Author:** ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)\
**Post date:** [January 9, 2020, 1:45pm UTC](https://discourse.julialang.org/t/nested-environments-in-package/33157/2 "2020-01-09T13:45:58Z")

</div>

What I do is ( `pwd` is the project folder )

```julia
pkg> activate examples
pkg> dev <Name of the Module>
pkg> add <Additional dependencies>

```

This will create the Project and Manifest-files in the examples directory.

---

<div class="post-metadata">

**Author:** ![racinmat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/racinmat/32/11715_2.png) [@racinmat](https://discourse.julialang.org/u/racinmat)\
**Post date:** [January 9, 2020, 2:00pm UTC](https://discourse.julialang.org/t/nested-environments-in-package/33157/3 "2020-01-09T14:00:11Z")

</div>

Thanks, I tried that, but this package I’m working on is not in registry yet, so the `dev <package> crashed`.  
I would like to use the source code I have in the project, not download it again.

---

<div class="post-metadata">

**Author:** ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)\
**Post date:** [January 9, 2020, 2:06pm UTC](https://discourse.julialang.org/t/nested-environments-in-package/33157/4 "2020-01-09T14:06:42Z")

</div>

It shouldn’t need to be registered. Try giving a path, maybe even `pkg> dev .` could work.

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [January 9, 2020, 5:10pm UTC](https://discourse.julialang.org/t/nested-environments-in-package/33157/5 "2020-01-09T17:10:47Z")

</div>

Also look at this related thread:

> [@Handling various types of dependencies](https://discourse.julialang.org/t/handling-various-types-of-dependencies/27850):
>
> (I apologize in advance for the very long post) As I use Julia for ever more complex and complete projects, I seem to run into the following problem, where a single “project” contains lots of related code, which will be used in different contexts to perform different tasks. (I’m speaking here of a “project” in the Github sense; from here on let’s imagine I’m speaking of a git repository, and reserve the words “package” and “project” to express the Julia concepts defined in the Pkg.jl documentat…

Some of the (sometimes prospective) solutions mentioned there might be of some interest to you:

- [stacked environments](https://discourse.julialang.org/t/handling-various-types-of-dependencies/27850/6) (but see the [concerns](https://discourse.julialang.org/t/handling-various-types-of-dependencies/27850/11) raised by such solutions)
- [Run.jl](https://github.com/tkf/Run.jl)
- [sub projects](https://github.com/JuliaLang/Pkg.jl/issues/1233)

---

<div class="post-metadata">

**Author:** ![racinmat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/racinmat/32/11715_2.png) [@racinmat](https://discourse.julialang.org/u/racinmat)\
**Post date:** [January 10, 2020, 9:52am UTC](https://discourse.julialang.org/t/nested-environments-in-package/33157/6 "2020-01-10T09:52:52Z")

</div>

Thanks, with `dev .` it worked exactly as I wanted.
