Disable automatic Pkg Garbage Collection

Once upon a time Pkg didn’t ever delete old versions of packages that were no longer in use.
Now it periodically does so automatically when doing other operations.
I would like that to stop, because I have so much hard-drive space.
Even the fractional chance of me needing it again is worth keeping it around.

How do I disable this?
I assume there is some method i need to monkey-patch, as i can’t find an environment variable in the docs.

2 Likes

I don’t think there’s a public way to do that at the moment:

You can do Pkg._auto_gc_enabled[] = false, but that’s not reliable across different versions.

3 Likes

Actually the problem can be more serious and a public API to set this would come in handy.

We had a scenario where we’d deploy an image with preinstalled Julia packates to create server instances in a cluster. As the image would get older, the auto_gc would kick in and introduce quite significant delays in the provisioning/startup time of the new instances.

We hacked it by using Pkg._auto_gc_enabled[] = false which worked (Julia 1.9 and 1.10).

3 Likes