# How to store the set of needed packages in git

**URL:** https://discourse.julialang.org/t/how-to-store-the-set-of-needed-packages-in-git/31975
**Category:** General Usage
**Tags:** question
**Created:** [December 7, 2019, 3:47pm UTC](https://discourse.julialang.org/t/how-to-store-the-set-of-needed-packages-in-git/31975 "2019-12-07T15:47:47Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [December 7, 2019, 3:47pm UTC](https://discourse.julialang.org/t/how-to-store-the-set-of-needed-packages-in-git/31975/1 "2019-12-07T15:47:48Z")

</div>

I know the possibility to “instantiate” a folder/project to load all the correct package versions, that are needed.

But how can I do the opposite, store a set of packages in a file that I can commit to git?

Uwe

---

<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: [December 7, 2019, 3:52pm UTC](https://discourse.julialang.org/t/how-to-store-the-set-of-needed-packages-in-git/31975/2 "2019-12-07T15:52:22Z")

</div>

I am not sure I got the question right, but checking in your `Project.toml` and/ or `Manifest.toml` should do the job.

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [December 7, 2019, 4:01pm UTC](https://discourse.julialang.org/t/how-to-store-the-set-of-needed-packages-in-git/31975/3 "2019-12-07T16:01:14Z")

</div>

Which Project.toml and/or Manifest.toml? And do I need them both?

I just checked, and in my project folder is none of these files.

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [December 7, 2019, 4:04pm UTC](https://discourse.julialang.org/t/how-to-store-the-set-of-needed-packages-in-git/31975/4 "2019-12-07T16:04:20Z")

</div>

the Manifest.toml describes the _exact_ set of packages you are using for development of your package. Since it will download the exact set of packages (and not just the most recent version-compatible set like Project.toml), there is no need to store all the packages locally or on a git repository.

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [December 7, 2019, 4:04pm UTC](https://discourse.julialang.org/t/how-to-store-the-set-of-needed-packages-in-git/31975/5 "2019-12-07T16:04:50Z")

</div>

But how can I create it?

---

<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: [December 7, 2019, 4:06pm UTC](https://discourse.julialang.org/t/how-to-store-the-set-of-needed-packages-in-git/31975/6 "2019-12-07T16:06:24Z")

</div>

Using the REPL you can write

```julia
] activate <Name of a folder>
add <List of Packages>

```

Now you have those files in the specified folder.

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [December 7, 2019, 4:15pm UTC](https://discourse.julialang.org/t/how-to-store-the-set-of-needed-packages-in-git/31975/7 "2019-12-07T16:15:12Z")

</div>

Ok, I have now the two above mentioned files.

Now I switched to julia 1.3, run  
]instantiate  
run my program, and it says: package xxx not found.

So my impression is that instantiate has no effect.

---

<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: [December 7, 2019, 4:16pm UTC](https://discourse.julialang.org/t/how-to-store-the-set-of-needed-packages-in-git/31975/8 "2019-12-07T16:16:12Z")

</div>

Did you activate the folder again? You will see it by the name of the blue prompt.

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [December 7, 2019, 4:21pm UTC](https://discourse.julialang.org/t/how-to-store-the-set-of-needed-packages-in-git/31975/9 "2019-12-07T16:21:38Z")

</div>

Ok, using

```julia
activate .

```

helped.

But when do I need to use activate, and when instantiate?

And do I need to commit both Project.toml and/or Manifest.toml?

---

<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: [December 7, 2019, 4:28pm UTC](https://discourse.julialang.org/t/how-to-store-the-set-of-needed-packages-in-git/31975/10 "2019-12-07T16:28:15Z")

</div>

Always activate the environment/project that you want to instantiate.  
If you just commit the the `Project.toml` instantiating will give you the most recent versions of Packages compatible with your `Project.toml` if you instantiate from the `Manifest.toml` you will get the exact versions that you had loaded at the time creating that `Manifest.toml`.  
What to commit depends on your usecase.  
Also have a glance at the [documentation](https://julialang.github.io/Pkg.jl/v1/toml-files/).

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [December 7, 2019, 4:37pm UTC](https://discourse.julialang.org/t/how-to-store-the-set-of-needed-packages-in-git/31975/11 "2019-12-07T16:37:56Z")

</div>

To summarize:  
a. to create a local Project.toml and Manifest.toml, first activate the project folder and then add all required packages  
b. commit both files, if you want to make sure a reproducible set of packages is used,  
if you want to use always the newest versions commit Project.toml only  
c. after check out execute both ]activate and ]instantiate  
d. after you have been working on a different project and you want to switch back it is sufficient to use only ]activate  
e. you can use `julia --project` to do the `activate` command when you start julia

Is my understanding correct?

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [December 7, 2019, 4:44pm UTC](https://discourse.julialang.org/t/how-to-store-the-set-of-needed-packages-in-git/31975/12 "2019-12-07T16:44:32Z")

</div>

yes and you can use `julia --project` to do the `activate` command when you start julia.

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [December 7, 2019, 4:45pm UTC](https://discourse.julialang.org/t/how-to-store-the-set-of-needed-packages-in-git/31975/13 "2019-12-07T16:45:40Z")

</div>

Thanks!

---

<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: [December 7, 2019, 4:46pm UTC](https://discourse.julialang.org/t/how-to-store-the-set-of-needed-packages-in-git/31975/14 "2019-12-07T16:46:25Z")

</div>

If you created the project on a given machine, you usually don’t need to instantiate. Only if you send code to others or to a different machine and then doing it once is enough.

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [December 7, 2019, 5:01pm UTC](https://discourse.julialang.org/t/how-to-store-the-set-of-needed-packages-in-git/31975/15 "2019-12-07T17:01:05Z")

</div>

Well, my colleagues might also update the package versions, so I have to instantiate after each checkout to be sure to use the same versions.

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [December 7, 2019, 6:02pm UTC](https://discourse.julialang.org/t/how-to-store-the-set-of-needed-packages-in-git/31975/16 "2019-12-07T18:02:34Z")

</div>

With a good enough test suite, this shouldn’t be a problem. Assuming people obey semver you really should only need the Project.toml and not the Manifest.toml.

---

<div class="post-metadata">

### Author: ![jkbest2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jkbest2/32/7350_2.png) [@jkbest2](https://discourse.julialang.org/u/jkbest2)
#### Post date: [December 7, 2019, 6:39pm UTC](https://discourse.julialang.org/t/how-to-store-the-set-of-needed-packages-in-git/31975/17 "2019-12-07T18:39:29Z")

</div>

I think the exception to this is if you depend on any unregistered packages.

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [December 7, 2019, 7:35pm UTC](https://discourse.julialang.org/t/how-to-store-the-set-of-needed-packages-in-git/31975/18 "2019-12-07T19:35:36Z")

</div>

Note that you can add package via a valid `git` URL and that package has a project.toml, things will work iirc. But yes for packages added via URL there won’t be a version number and only the Manifest.toml will have the unique git hash that identifies what the repository looked like at the exact moment it was added.

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [December 7, 2019, 7:42pm UTC](https://discourse.julialang.org/t/how-to-store-the-set-of-needed-packages-in-git/31975/19 "2019-12-07T19:42:16Z")

</div>

Though you _can_ add a particular commit for a repository, which means you can still work using only `Project.toml`

---

<div class="post-metadata">

### Author: ![jkbest2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jkbest2/32/7350_2.png) [@jkbest2](https://discourse.julialang.org/u/jkbest2)
#### Post date: [December 8, 2019, 12:09am UTC](https://discourse.julialang.org/t/how-to-store-the-set-of-needed-packages-in-git/31975/20 "2019-12-08T00:09:50Z")

</div>

I haven’t had had luck with this. For example, the [`Project.toml` for one of my unregistered packages](https://github.com/jkbest2/FisherySim.jl/blob/master/Project.toml) includes a dependence on another unregistered packages (`TweedieDistributions.jl`), but only includes the UUIDs for each package so there’s no way to find the package from only the `Project.toml` file.

[Next page](https://discourse.julialang.org/t/how-to-store-the-set-of-needed-packages-in-git/31975.md?page=2)
