# Notebook-specific target/Project.toml (similar to test)

**URL:** <https://discourse.julialang.org/t/notebook-specific-target-project-toml-similar-to-test/125972>\
**Category:** General Usage\
**Tags:** question, pkg\
**Created:** [February 17, 2025, 12:45am UTC](https://discourse.julialang.org/t/notebook-specific-target-project-toml-similar-to-test/125972 "2025-02-17T00:45:50Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![brunompacheco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brunompacheco/32/209375_2.png) [@brunompacheco](https://discourse.julialang.org/u/brunompacheco)\
**Post date:** [February 17, 2025, 12:45am UTC](https://discourse.julialang.org/t/notebook-specific-target-project-toml-similar-to-test/125972/1 "2025-02-17T00:45:50Z")

</div>

Greetings,

I am developing a Julia package in which I have some Jupyter notebooks. Those notebooks use some packages that I do not want to include as general project dependencies (e.g., Plots.jl). However, I do not seem to find a way to manage that.

So far, I have tried the two approaches suggested for handling tests. Given that notebooks are in a `notebooks/` folder, I first tried adding a new target to match that, but the Jupyter notebooks do not activate the project. Then, I tried having another Project.toml file inside the notebooks dir, but since the notebook won’t merge automatically with the parent Project.toml file, I don’t even know how to include the parent package as a dependency.

---

<div class="post-metadata">

**Author:** ![danielwe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielwe/32/35657_2.png) [@danielwe](https://discourse.julialang.org/u/danielwe)\
**Post date:** [February 17, 2025, 5:30am UTC](https://discourse.julialang.org/t/notebook-specific-target-project-toml-similar-to-test/125972/2 "2025-02-17T05:30:20Z")

</div>

> [@brunompacheco](#):
>
> Then, I tried having another Project.toml file inside the notebooks dir, but since the notebook won’t merge automatically with the parent Project.toml file, I don’t even know how to include the parent package as a dependency.

This is the way to go. To add the parent directory you use its relative path `..`. You probably want to use `dev` rather than `add`, since you presumably want your notebooks to use the current state of the files rather than a specific commit or release. Thus, the commands will look something like this:

```bash
$ cd notebooks

$ julia --project=.

```

```julia-repl
julia> # hit ] to enter pkg mode

(notebooks) pkg> dev ..
   Resolving package versions...
    Updating `~/ParentPackage/notebooks/Project.toml`
  [336d156d] + ParentPackage v0.1.0 `..`
    Updating `~/ParentPackage/notebooks/Manifest.toml`
  [...]

```

For this to work, the parent directory must contain a package as generated by `pkg> generate` or PkgTemplates.jl, not just a barebones project environment. Specifically, the parent directory’s Project.toml must contain a name and an UUID.

---

<div class="post-metadata">

**Author:** ![xgdgsc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xgdgsc/32/608_2.png) [@xgdgsc](https://discourse.julialang.org/u/xgdgsc)\
**Post date:** [February 17, 2025, 5:47am UTC](https://discourse.julialang.org/t/notebook-specific-target-project-toml-similar-to-test/125972/3 "2025-02-17T05:47:14Z")

</div>

Use the global env for those packages like `Plots.jl` or setup [GitHub - GunnarFarneback/LocalRegistry.jl: Create and maintain local registries for Julia packages.](https://github.com/GunnarFarneback/LocalRegistry.jl) and create a separate package for notebooks.

---

<div class="post-metadata">

**Author:** ![brunompacheco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brunompacheco/32/209375_2.png) [@brunompacheco](https://discourse.julialang.org/u/brunompacheco)\
**Post date:** [February 19, 2025, 6:22pm UTC](https://discourse.julialang.org/t/notebook-specific-target-project-toml-similar-to-test/125972/4 "2025-02-19T18:22:03Z")

</div>

Although I wish I could take the target approach, I’m currently keeping the separate Project.toml file, as suggested by @danielwe.

In case it’s useful for anyone facing the same challenge, I indeed added the parent package as a development dependency, and to access its dependencies I just do `using A.B` (found out about that [here](https://discourse.julialang.org/t/how-to-add-all-dependencies-of-a-package-to-global-environment/19725/8)).

---

<div class="post-metadata">

**Author:** ![danielwe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielwe/32/35657_2.png) [@danielwe](https://discourse.julialang.org/u/danielwe)\
**Post date:** [February 19, 2025, 7:12pm UTC](https://discourse.julialang.org/t/notebook-specific-target-project-toml-similar-to-test/125972/5 "2025-02-19T19:12:56Z")

</div>

If you’re actually using `B` in your notebooks, why not add it explicitly to the notebook env? By relying on `using A.B` you’re introducing a very tight coupling between the notebooks and implementation details of `A`, which will be a hassle whenever you want to refactor and reconsider dependencies in `A`.

> [@brunompacheco](#):
>
> Although I wish I could take the target approach

The `[targets]` approach is not expected to work. As far as I understand it currently only supports `test`.

---

<div class="post-metadata">

**Author:** ![brunompacheco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brunompacheco/32/209375_2.png) [@brunompacheco](https://discourse.julialang.org/u/brunompacheco)\
**Post date:** [February 21, 2025, 10:44pm UTC](https://discourse.julialang.org/t/notebook-specific-target-project-toml-similar-to-test/125972/6 "2025-02-21T22:44:06Z")

</div>

I use the notebooks for usage examples of `A` and for some development (experimentation), so it is relevant to me, for example, that the version of `B` in the notebooks is the same as in `A`.

---

<div class="post-metadata">

**Author:** ![danielwe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielwe/32/35657_2.png) [@danielwe](https://discourse.julialang.org/u/danielwe)\
**Post date:** [February 21, 2025, 11:22pm UTC](https://discourse.julialang.org/t/notebook-specific-target-project-toml-similar-to-test/125972/7 "2025-02-21T23:22:41Z")

</div>

> [@brunompacheco](#):
>
> the version of `B` in the notebooks is the same as in `A`

That will always be the case. A julia environment will only ever contain one version of a package. When you do

```julia-repl
(notebooks) pgk> dev .. # contains A, which depends on B

(notebooks) pkg> add B

```

then the second command does _almost_ nothing—`B` was already installed in the environment when you did `dev ..` because it’s needed by `A` (you can run `pkg> status --manifest` to see the complete list of installed packages). The only difference after `add B` is that you can now do `using B` instead of having to access `B` indirectly as `A.B`.

---

<div class="post-metadata">

**Author:** ![brunompacheco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brunompacheco/32/209375_2.png) [@brunompacheco](https://discourse.julialang.org/u/brunompacheco)\
**Post date:** [February 21, 2025, 11:40pm UTC](https://discourse.julialang.org/t/notebook-specific-target-project-toml-similar-to-test/125972/8 "2025-02-21T23:40:23Z")

</div>

I thought one of the reasons behind not making the dependencies of a package already available was to allow each package to have different versions of a shared dependency. So I believed there would be no guarantee that, once I update B in A, the version of B in notebooks would also be updated.

Also, is that the case for unregistered dependencies?

---

<div class="post-metadata">

**Author:** ![danielwe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielwe/32/35657_2.png) [@danielwe](https://discourse.julialang.org/u/danielwe)\
**Post date:** [February 21, 2025, 11:49pm UTC](https://discourse.julialang.org/t/notebook-specific-target-project-toml-similar-to-test/125972/9 "2025-02-21T23:49:58Z")

</div>

> [@brunompacheco](#):
>
> allow each package to have different versions of a shared dependency

No, this is not currently possible, though it does come up as a feature request from time to time. Currently, only a single version of each package can be loaded in any julia session.

> [@brunompacheco](#):
>
> Also, is that the case for unregistered dependencies?

I’m pretty sure it’s the case for any code loaded via `using` or `import`. To get around it you’d have to manually copy/`include` the relevant code such that it becomes part of your package rather than a managed dependency.

---

<div class="post-metadata">

**Author:** ![danielwe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielwe/32/35657_2.png) [@danielwe](https://discourse.julialang.org/u/danielwe)\
**Post date:** [February 21, 2025, 11:53pm UTC](https://discourse.julialang.org/t/notebook-specific-target-project-toml-similar-to-test/125972/10 "2025-02-21T23:53:08Z")

</div>

> [@danielwe](#):
>
> only a single version of each package can be loaded in any julia session.

In fact, if this weren’t the case it wouldn’t be possible for julia packages to compose the way they do, where package `C` can use a method that package `B` adds to a function defined in package `A`.
