# It takes several minutes to add a single package

**URL:** <https://discourse.julialang.org/t/it-takes-several-minutes-to-add-a-single-package/70704>\
**Category:** New to Julia\
**Tags:** pkg, environment\
**Created:** [October 31, 2021, 8:59pm UTC](https://discourse.julialang.org/t/it-takes-several-minutes-to-add-a-single-package/70704 "2021-10-31T20:59:07Z")\
**Posts on this page:** 6\
**Page:** 6

<div class="post-metadata">

**Author:** ![acarta](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/acarta/32/28474_2.png) [@acarta](https://discourse.julialang.org/u/acarta)\
**Post date:** [November 3, 2021, 2:04pm UTC](https://discourse.julialang.org/t/it-takes-several-minutes-to-add-a-single-package/70704/101 "2021-11-03T14:04:49Z")

</div>

You could try modifying the `[compat]` entries in your `Project.toml`. If you change the relevant entry to something like `MyPackage "= 4.4"`, that package will be locked at version 4.4 and won’t update, as opposed to the default `MyPackage = "4.4"`, which signals `Pkg` to look for and pull in the latest compatible version that’s compatible with `4.4`, i.e. anything up to, but not including, `5.0`.

Of course, this can be a bit tedious for larger projects, and is probably not a good idea in the default environment, but it might help ameliorate the problem you’re describing,

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [November 3, 2021, 2:30pm UTC](https://discourse.julialang.org/t/it-takes-several-minutes-to-add-a-single-package/70704/102 "2021-11-03T14:30:33Z")

</div>

> [@acarta](#):
>
> Of course, this can be a bit tedious for larger projects, and is probably not a good idea in the default environment, but it might help ameliorate the problem you’re describing,

No, the solution is simply [one line in my `startup.jl`](https://discourse.julialang.org/t/it-takes-several-minutes-to-add-a-single-package/70704/78) that prevents Julia from updating the registry unless I explicitly ask it to. (Pinning package versions manually, in comparison, is a huge pain to set up, is fragile because it requires me to know way too much about the requirements of individual packages, and is an ongoing headache to update later.)

The only question in my mind is what is a better _default_ experience for new users?

1. Only updating the registry when explicitly asked (similar to conda and many other packaging systems). Pro: fast to add packages, and adding a package won’t accidentally break other working user code. Con: adding a new package may not give the latest version.

2. Updating the registry, and potentially many other packages, whenever a package is added. Pro: adding a package gets the latest version if possible. Con: adding packages can be slow and can trigger undesired updates of other packages (unless the user is very conscientious about managing environments and requirements for their projects).

---

<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:** [November 3, 2021, 2:32pm UTC](https://discourse.julialang.org/t/it-takes-several-minutes-to-add-a-single-package/70704/103 "2021-11-03T14:32:15Z")

</div>

Stata gives a somewhat helpful nudge

> It’s been 7 days since we last checked for updates. Would you like to check now? (y/n)

You can ignore it if you know all your packages are very stable. But it’s nice to get a reminder of when it’s time to check the registry for new versions.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [November 3, 2021, 2:56pm UTC](https://discourse.julialang.org/t/it-takes-several-minutes-to-add-a-single-package/70704/104 "2021-11-03T14:56:54Z")

</div>

There are two disjoint discussions going on here. One is, how Pkg should behave when you do `add Package`. In this case, we seem to be quite similar to conda:

> Conda attempts to install the newest versions of the requested packages. To accomplish this, it may update some packages that are already installed, or install additional packages. To prevent existing packages from updating, use the --freeze-installed option. This may force conda to install older versions of the requested packages, and it does not prevent additional dependency packages from being installed.

The other discussion is how frequently the registry should update. Personally, I feel that every session is indeed a bit too often and I do in fact run with that same thing in my `startup.jl`. I think @StefanKarpinski has quite strongly argued for updating it every time on `add` though. I think opening an issue to discuss it would be a good idea.

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [November 3, 2021, 3:51pm UTC](https://discourse.julialang.org/t/it-takes-several-minutes-to-add-a-single-package/70704/105 "2021-11-03T15:51:52Z")

</div>

This is very much what we do for `] gc` already (at least in 1.7). Every once in a while it reminds me that things haven’t been gc’ed lately and goes ahead and does it. I like it!

---

<div class="post-metadata">

**Author:** ![HanD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hand/32/213908_2.png) [@HanD](https://discourse.julialang.org/u/HanD)\
**Post date:** [November 8, 2021, 8:11am UTC](https://discourse.julialang.org/t/it-takes-several-minutes-to-add-a-single-package/70704/106 "2021-11-08T08:11:46Z")

</div>

Boy, is this a long topic or what! I started reading through it, but I gave up when I realized I’m only tenth of the way down.

Anyhow, _in case_ the situation has not resolved itself yet, I had a very similar issue with a registry that has been in use since Julia 1.0, and continuously upgraded. I posted a similar question [here](https://discourse.julialang.org/t/is-there-a-way-to-prevent-julia-from-updating-the-registries-almostevery-time/64150), although I did not complain primarily about the time it takes to udate the registry, rather than the amount of network traffic. Still, the apparent solution to both issues was to simply delete and readd the General registry. I stopped having issues with the updates since then. If your issue still persists, it’s worth a shot IMHO.

[Previous page](https://discourse.julialang.org/t/it-takes-several-minutes-to-add-a-single-package/70704.md?page=5)
