# Correct way to prepare dependencies of a julia project for publishing?

**URL:** <https://discourse.julialang.org/t/correct-way-to-prepare-dependencies-of-a-julia-project-for-publishing/77176>\
**Category:** General Usage\
**Tags:** question\
**Created:** [February 28, 2022, 11:08am UTC](https://discourse.julialang.org/t/correct-way-to-prepare-dependencies-of-a-julia-project-for-publishing/77176 "2022-02-28T11:08:56Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin\_Shen1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevin_shen1/32/33160_2.png) [@Kevin\_Shen1](https://discourse.julialang.org/u/Kevin_Shen1)\
**Post date:** [February 28, 2022, 11:08am UTC](https://discourse.julialang.org/t/correct-way-to-prepare-dependencies-of-a-julia-project-for-publishing/77176/1 "2022-02-28T11:08:56Z")

</div>

I come from python where each environment has an independent list of packages. This simplifies publishing the project to github because you can just install from a requirements.txt file.

According to this Q&A [Understanding environments and projects](https://discourse.julialang.org/t/understanding-environments-and-projects/25741), Julia has a stack of environments from which it will pull packages. How do I achieve the same behavior when I publish my project to github (i.e. create a list of packages the project depends on so end-users can clone the repo and just run “install requirements.txt”? The problem is given Julia has an environment stack it pulls packages from when you do “using X”, Project.toml for the current project doesn’t list all the packages you’re actually using.

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [February 28, 2022, 11:52am UTC](https://discourse.julialang.org/t/correct-way-to-prepare-dependencies-of-a-julia-project-for-publishing/77176/2 "2022-02-28T11:52:28Z")

</div>

> [@Kevin\_Shen1](#):
>
> Project.toml for the current project doesn’t list all the packages you’re actually using.

Right, that’s what the Manifest.toml file is for.

It seems you’re after this info (more or less): [Frequently Asked Questions · The Julia Language](https://docs.julialang.org/en/v1/manual/faq/)

> If you want to reproduce not only the set of packages, but also the versions you were using in the previous Julia version, you should also copy the Manifest.toml file before running the Pkg command `instantiate`.

[https://pkgdocs.julialang.org/v1/toml-files/#Manifest.toml](https://pkgdocs.julialang.org/v1/toml-files/#Manifest.toml)

---

<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:** [February 28, 2022, 12:35pm UTC](https://discourse.julialang.org/t/correct-way-to-prepare-dependencies-of-a-julia-project-for-publishing/77176/3 "2022-02-28T12:35:24Z")

</div>

As I understand it, the stack of environments is only there so that you can use tooling (such as `Revise`, `Debugger`…) in an interactive context while developing: these package introducing tools can be installed once and for all in the default environment (on top of which the active project’s environment is stacked).  
The packages that are actually dependencies of your project (i.e. packages for which there are `using` or `import` statements in your project code) should all be listed in the project’s environment.

This list of (direct) dependencies is stored in the `Project.toml` file, which you can update _via_ the [`add`](https://pkgdocs.julialang.org/v1/managing-packages/#Adding-registered-packages)/`rm` commands of the package manager.

If you forget to explicitly list a dependency, things might still work (because of stacked environments, or because it’s a standard library), but you’ll still get a warning during tests, and also when you try using your package and it gets precompiled. This helps maintaining `Project.toml` up-to-date.

```julia
julia> using Foo
[Info: Precompiling Foo [e0958bea-714e-463a-a34c-e3fc1ef883d0]
┌ Warning: Package Foo does not have LinearAlgebra in its dependencies:
│ - If you have Foo checked out for development and have
│ added LinearAlgebra as a dependency but haven't updated your primary
│ environment's manifest file, try `Pkg.resolve()`.
│ - Otherwise you may need to report an issue with Foo
└ Loading LinearAlgebra into Foo from project dependency, future warnings for Foo are suppressed.

```

In order to install the dependencies on a new system, your users (or your future self) only need to run the package manager [`instantiate`](https://pkgdocs.julialang.org/v1/environments/#Using-someone-else's-project) command. As said in previous posts, if you ship the `Manifest.toml` file alongside your sources, the full environment will even get entirely reproduced (i.e. the full list of direct and indirect dependencies, each in their own specific version).

---

<div class="post-metadata">

**Author:** ![lrnv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lrnv/32/19373_2.png) [@lrnv](https://discourse.julialang.org/u/lrnv)\
**Post date:** [February 28, 2022, 12:36pm UTC](https://discourse.julialang.org/t/correct-way-to-prepare-dependencies-of-a-julia-project-for-publishing/77176/4 "2022-02-28T12:36:47Z")

</div>

> [@ffevotte](#):
>
> As said in previous posts, if you ship the `Manifest.toml` file alongside your sources, the full environment will even get entirely reproduced (i.e. the full list of direct and indirect dependencies, each in their own specific version).

This seems to work correctly for packages, but what about the version of Julia itself ?

---

<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:** [February 28, 2022, 12:40pm UTC](https://discourse.julialang.org/t/correct-way-to-prepare-dependencies-of-a-julia-project-for-publishing/77176/5 "2022-02-28T12:40:55Z")

</div>

> [@lrnv](#):
>
> This seems to work correctly for packages, but what about the version of Julia itself ?

Yes, your’re right to point this out: the contents of the Manifest depend on the version of Julia itself; your users need to use the same version if they want to reproduce everything.

---

<div class="post-metadata">

**Author:** ![lrnv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lrnv/32/19373_2.png) [@lrnv](https://discourse.julialang.org/u/lrnv)\
**Post date:** [February 28, 2022, 12:43pm UTC](https://discourse.julialang.org/t/correct-way-to-prepare-dependencies-of-a-julia-project-for-publishing/77176/6 "2022-02-28T12:43:23Z")

</div>

Is’nt there a plan to modify Project.toml to potentially include julia version in future releases ? I thought I saw something like that in a PR or in release notes.

---

<div class="post-metadata">

**Author:** ![mrVeng](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mrveng/32/8836_2.png) [@mrVeng](https://discourse.julialang.org/u/mrVeng)\
**Post date:** [February 28, 2022, 12:45pm UTC](https://discourse.julialang.org/t/correct-way-to-prepare-dependencies-of-a-julia-project-for-publishing/77176/7 "2022-02-28T12:45:10Z")

</div>

I think as of Julia 1.7, this should be under `[compat]` in `Project.toml`.

---

<div class="post-metadata">

**Author:** ![lrnv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lrnv/32/19373_2.png) [@lrnv](https://discourse.julialang.org/u/lrnv)\
**Post date:** [February 28, 2022, 12:50pm UTC](https://discourse.julialang.org/t/correct-way-to-prepare-dependencies-of-a-julia-project-for-publishing/77176/8 "2022-02-28T12:50:11Z")

</div>

Haa i found it:

> [@https://docs.julialang.org/en/v1/NEWS/](#):
>
> A new `Manifest.toml` format is now used that captures extensible metadata fields, including the julia version that generated the manifest. Old format manifests are still supported and will be maintained in their original format, unless the user runs `Pkg.upgrade_manifest()` to upgrade the format of the current environment’s manifest without re-resolving ([#40765](https://github.com/JuliaLang/julia/issues/40765)).

Moreover, this was backported to 1.6.2 LTS accoridng to the github discussion linked.

So NVM, sharing your manifest is enough for total reproducibility starting from 1.6.2

---

<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:** [February 28, 2022, 12:50pm UTC](https://discourse.julialang.org/t/correct-way-to-prepare-dependencies-of-a-julia-project-for-publishing/77176/9 "2022-02-28T12:50:25Z")

</div>

> [@lrnv](#):
>
> Is’nt there a plan to modify Project.toml to potentially include julia version in future releases ? I thought I saw something like that in a PR or in release notes.

The version of Julia is included in the generated Manifest.toml (not sure since when). So you can know which version to install in order to use a particular Manifest, but the package manager does not install Julia for you (that’s how I understood your first question)

You should include compatibility bounds for all dependencies of your project (including Julia itself) in the `Project.toml` file. AFAIU These will be used to resolve a consistent environment when needed (i.e. when you do not already have an adequate `Manifest.toml`)

---

<div class="post-metadata">

**Author:** ![lrnv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lrnv/32/19373_2.png) [@lrnv](https://discourse.julialang.org/u/lrnv)\
**Post date:** [February 28, 2022, 12:52pm UTC](https://discourse.julialang.org/t/correct-way-to-prepare-dependencies-of-a-julia-project-for-publishing/77176/10 "2022-02-28T12:52:26Z")

</div>

> [@ffevotte](#):
>
> The version of Julia is included in the generated Manifest.toml (not sure since when). So you can know which version to install in order to use a particular Manifest, but the package manager does not install Julia for you (that’s how I understood your first question)

Yes changing julia version is not automatic 😉 Although there is [GitHub - LilithHafner/UpdateJulia.jl: Simple cross platform Julia installer](https://github.com/LilithHafner/UpdateJulia.jl)
