# Is there a way to prevent Julia from updating the registries almost every time?

**URL:** <https://discourse.julialang.org/t/is-there-a-way-to-prevent-julia-from-updating-the-registries-almost-every-time/64150>\
**Category:** Package Management\
**Tags:** git, update\
**Created:** [July 6, 2021, 2:31pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-prevent-julia-from-updating-the-registries-almost-every-time/64150 "2021-07-06T14:31:54Z")\
**Posts on this page:** 20\
**Page:** 1

<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:** [July 6, 2021, 2:31pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-prevent-julia-from-updating-the-registries-almost-every-time/64150/1 "2021-07-06T14:31:55Z")

</div>

Whenever I do something with the package manager, it tends to begin by updating the installed registries, including the General registry. This can happen several times a day, understandably, since the General registry includes a large number of packages, which are updated regularly.

This operation, however, takes a significant amount of time, and what is worse, it generates about 100 MB of network traffic. When I’m working over a mobile data network, this is means a significant toll on my data plan.

I began to wonder, is there a way to prevent such automatic updates? I don’t mind not getting the newest and latest from each and every package I install, as long as I stay in control when the registry is updated.

---

<div class="post-metadata">

**Author:** ![mcabbott](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcabbott/32/6603_2.png) [@mcabbott](https://discourse.julialang.org/u/mcabbott)\
**Post date:** [July 6, 2021, 2:53pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-prevent-julia-from-updating-the-registries-almost-every-time/64150/2 "2021-07-06T14:53:40Z")

</div>

You can add something like this to `.julia/config/startup.jl`:

```julia
using Pkg: Pkg
Pkg.UPDATED_REGISTRY_THIS_SESSION[] = true
# and other stuff, deleted...

```

Type `] up` to update both the registry and packages, just `] add` will work from the existing copy of the registry.

---

<div class="post-metadata">

**Author:** ![ianshmean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ianshmean/32/216042_2.png) [@ianshmean](https://discourse.julialang.org/u/ianshmean)\
**Post date:** [July 6, 2021, 2:55pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-prevent-julia-from-updating-the-registries-almost-every-time/64150/3 "2021-07-06T14:55:22Z")

</div>

> [@mcabbott](#):
>
> `ENV["JULIA_NUM_PRECOMPILE_TASKS"] = 4`

I think you included this accidentally? (It has nothing to do with @HanD’s issue)

---

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [July 6, 2021, 3:16pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-prevent-julia-from-updating-the-registries-almost-every-time/64150/4 "2021-07-06T15:16:21Z")

</div>

> [@mcabbott](#):
>
> ```julia
> using Pkg: Pkg
> Pkg.UPDATED_REGISTRY_THIS_SESSION[] = true
> # and other stuff, deleted...
> 
> ```
> 
> Type `] up` to update both the registry and packages, just `] add` will work from the existing copy of the registry.

Nice, I wonder why this is not the default behavior? (the user can always do `registry up` before `add` if desired).

---

<div class="post-metadata">

**Author:** ![jonathanBieler](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jonathanBieler](https://discourse.julialang.org/u/jonathanBieler)\
**Post date:** [July 6, 2021, 3:17pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-prevent-julia-from-updating-the-registries-almost-every-time/64150/5 "2021-07-06T15:17:28Z")

</div>

Maybe the time of last update should be logged in `.julia/logs` so you can have a timeout of one day or something on updating the registry. Sessions can be short lived so I’m not sure they are the right thing to track, and surely people that need frequent updates of the registry (not sure who that is?) are in the minority, so they would have to be the ones asking for an explicit update.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [July 6, 2021, 3:23pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-prevent-julia-from-updating-the-registries-almost-every-time/64150/6 "2021-07-06T15:23:10Z")

</div>

because we will then get even more “why ]up doesn’t update my pkg”, imagine you only have `apt upgrade` not `update` but somehow the default behavior doesn’t contain `update` and user has to `sudoedit /etc/apt/blah...` before running `sudo apt upgrade`.

I’m fine if we add a command called `registry freeze` but I think when user `]up`, they expect to download artifacts etc. for newer versions of their packages anyways.

---

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [July 6, 2021, 3:25pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-prevent-julia-from-updating-the-registries-almost-every-time/64150/7 "2021-07-06T15:25:01Z")

</div>

But we do have `apt update` (we have `registry up`)…

---

<div class="post-metadata">

**Author:** ![jdad](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jdad/32/4739_2.png) [@jdad](https://discourse.julialang.org/u/jdad)\
**Post date:** [July 6, 2021, 3:27pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-prevent-julia-from-updating-the-registries-almost-every-time/64150/8 "2021-07-06T15:27:40Z")

</div>

I would suppose you are running Windows, where registry update is fairly slow as of now because of Defender interaction. Should be much faster (=similar to Linux) with 1.7 as there will be no registry extraction - so, you could try 1.7.0-beta2 to see if it is better for you?

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [July 6, 2021, 3:34pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-prevent-julia-from-updating-the-registries-almost-every-time/64150/9 "2021-07-06T15:34:54Z")

</div>

> [@sijo](#):
>
> I wonder why this is not the default behavior?

> [@jdad](#):
>
> I would suppose you are running Windows, where registry update is fairly slow as of now because of Defender interaction.

Indeed, for reference, this is the experience for me (on Linux):

```julia
julia> @time Pkg.Registry.update()
    Updating registry at `~/.julia/registries/General`
  0.043207 seconds (24.52 k allocations: 2.452 MiB)

```

> [@jdad](#):
>
> Should be much faster (=similar to Linux) with 1.7 as there will be no registry extraction - so, you could try 1.7.0-beta2 to see if it is better for you?

Yes, should be much better for everyone, but in particular for Windows users.

---

<div class="post-metadata">

**Author:** ![tchr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tchr/32/15138_2.png) [@tchr](https://discourse.julialang.org/u/tchr)\
**Post date:** [July 7, 2021, 12:18am UTC](https://discourse.julialang.org/t/is-there-a-way-to-prevent-julia-from-updating-the-registries-almost-every-time/64150/10 "2021-07-07T00:18:45Z")

</div>

Aside from the improvements coming in 1.7 for Windows users, it still seems to be a valid concern that so much network traffic is generated just to force registry updates (I didn’t know it was on the order of 100 MB, at least). That seems excessive if all one wants to do is add one small package (at least, for me, it’s seldom a priority to be on a sub-one-day bleeding edge registry version; and if it is, I can do `registry up`). Summed up across all Julia users, that’s a lot of data and energy.

I also think some sort of time-out option would be meaningful.

---

<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:** [July 7, 2021, 8:06am UTC](https://discourse.julialang.org/t/is-there-a-way-to-prevent-julia-from-updating-the-registries-almost-every-time/64150/11 "2021-07-07T08:06:04Z")

</div>

Wow, that’s very useful to know, thanks @mcabbott! I wonder why this workaround isn’t documented at all. I will definitely do this.

---

<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:** [July 7, 2021, 8:13am UTC](https://discourse.julialang.org/t/is-there-a-way-to-prevent-julia-from-updating-the-registries-almost-every-time/64150/12 "2021-07-07T08:13:00Z")

</div>

Good guess, but no, I’m using Linux, _but_ with ZFS, and I heard or read somewhere that ZFS and the unpacking of the registry does not cope well. So, Julia 1.7 should improve that, too. I will give it a shot as soon as the release comes out.

Note, however, that my main concern was the network usage, not the speed. Still, thanks for the insight!

---

<div class="post-metadata">

**Author:** ![ElOceanografo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eloceanografo/32/624_2.png) [@ElOceanografo](https://discourse.julialang.org/u/ElOceanografo)\
**Post date:** [July 7, 2021, 4:36pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-prevent-julia-from-updating-the-registries-almost-every-time/64150/13 "2021-07-07T16:36:23Z")

</div>

I recently ran into this problem while working on a ship with a satellite internet connection. Just updating the packages in a local project (to versions I’d already downloaded and installed in the global environment) triggered a re-download of the whole registry, which was a huge PITA. Having a simple option like `registry freeze`, or just documentation of @mcabbot’s workaround, would be great.

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [July 7, 2021, 4:57pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-prevent-julia-from-updating-the-registries-almost-every-time/64150/14 "2021-07-07T16:57:30Z")

</div>

I think part of the problem is that registry updates currently requires O(# of packages) communication. I think we could lower that to O(# of outdated packages) by having the client send when they last updated the registry.

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [July 7, 2021, 5:09pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-prevent-julia-from-updating-the-registries-almost-every-time/64150/15 "2021-07-07T17:09:45Z")

</div>

there is also `Pkg.offline()` btw

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [July 7, 2021, 5:16pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-prevent-julia-from-updating-the-registries-almost-every-time/64150/16 "2021-07-07T17:16:32Z")

</div>

If I remember correctly, at some point someone looked into transmitting only a diff of the registry, but probably before the recent work about keeping the registry in a tarball

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [July 7, 2021, 5:26pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-prevent-julia-from-updating-the-registries-almost-every-time/64150/17 "2021-07-07T17:26:17Z")

</div>

I don’t think a diff is the right answer. That would add a ton of work server side. I think the easiest thing that will get the same benefits is having the package server have separate tarballs for today, this week, this month, and all time. That way we don’t have to calculate diffs on the fly, but still get 90% of the benefit.

---

<div class="post-metadata">

**Author:** ![jonathanBieler](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jonathanBieler](https://discourse.julialang.org/u/jonathanBieler)\
**Post date:** [July 7, 2021, 7:27pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-prevent-julia-from-updating-the-registries-almost-every-time/64150/18 "2021-07-07T19:27:06Z")

</div>

Is there any issues with just updating the registry at most once a day ? It seems the only people that would need more frequent updates are the one actively registering packages and testing them out, but in that case they can just do a `]up`.

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [July 7, 2021, 9:24pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-prevent-julia-from-updating-the-registries-almost-every-time/64150/19 "2021-07-07T21:24:22Z")

</div>

@staticfloat and I are already working on this. The rough plan is still what was outlined in the original [Pkg protocol issue](https://github.com/JuliaLang/Pkg.jl/issues/1377). Diffs between the registry tarball that the user has and the one that they’re downloading will be computed with the [BSDiff package](https://github.com/JuliaIO/BSDiff.jl), which has the ability — absent from the similarly named command-line tool — to generate an index (it’s a [suffix array](https://github.com/JuliaCollections/SuffixArrays.jl), to be technical about it) for each old file that speeds up generation of diffs for different new files. Generating an index for a registry tarball takes several seconds but once you have an index for the old version, generating a diff with any given new registry tarball takes about half a second. We will cache both index files and pairwise diffs, on the premise that both will have good temporal cache locality: if one person is upgrading from a given registry version, chances are many people will be upgrading from that same registry version; if one person upgrades from registry version A to B, chances are other people will need the same diff. Serving a cache hit for an exact registry diff will be basically instantaneous and the diffs are very compact.

There are lots of tricky details, but it has pretty much all been worked out at this point. For example, you want to minimize diffs by using a stable, consistent tarball format that orders content consistently and doesn’t capture a lot of irrelevant details that change arbitrarily, like timestamps, user/group IDs, detailed permissions beyond what git cares about. That’s one of the reasons I created the [Tar](https://github.com/JuliaIO/Tar.jl) package, which is now a stdlib and is used to generate standardized tarballs that are served by Pkg servers — it does all of that by design and more: if two trees have the same git tree hash, then if you generate tarballs for them, those tarballs will be the same. This actually isn’t necessary for diffing registry tarballs that we don’t extract, but becomes important if we’re going to be able to use diffs for things that we do extract, like packages and artifacts. (Because you need to be able to reconstruct the old tarball in order to apply a patch to it.)

The diffs created this way are quite tiny, so they should massively help in situations where someone is on a slow connection. With that change I highly doubt that it will be necessary to throttle registry updates (they’re already throttled to once per Julia session). We could potentially still add a “no more often than X minutes” limit on updates if someone cares to implement that.

---

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [July 7, 2021, 11:00pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-prevent-julia-from-updating-the-registries-almost-every-time/64150/20 "2021-07-07T23:00:06Z")

</div>

I’ve got my home directory on an NFS server which is served by a glusterfs cluster. On glusterfs stat is not a trivial operation. The first time I built the registry in my home dir it took a LONG time, on Linux. Could have been an hour. I haven’t tried to do PKG installs yet but I suspect it’s nontrivial. The registry filesystem tree is quite large and this means a lot of time to traverse it. I realize this is a bit of an edge case.

[Next page](https://discourse.julialang.org/t/is-there-a-way-to-prevent-julia-from-updating-the-registries-almost-every-time/64150.md?page=2)
