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,
No, the solution is simply one line in my startup.jl 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?
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.
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).
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.
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.
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!
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, 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.