How to garbage collect pacakges regardless or last used date?

I recall reading somewhere that ]gc is conservative and only remove packages that haven’t been used in the last 1 month.

My question how do I do it more aggressively so that I can remove a package that is no longer required regardless of when it was last used?

The use-case is in build docker images. I have built a docker image by using PackageCompilerX.jl to compile some packages but now I don’t require PackageCompilerX any more so I

]rm PackageCompilerX
]gc

but then ]gc doesn’t seem to do much. Hopefully, this makes it much more googlable.

1 Like

On master, I believe that you can use gc --all.

@00vareladavid will know more.

1 Like

by the way ]?gc didn’t show the options either. Might help add that

On master, if I input ]?gc, I get this:

(@v1.4) pkg> ?gc
  gc [--all]

  Free disk space by garbage collecting packages not used for a significant time. The
  --all option will garbage collect all packages which can not be immediately reached
  from any existing project.
3 Likes

I missed that. I am using the julia:1.3 docker image.

image

Yeah you’ll need a relatively recent master or a relatively recent nightly.

From the docs

using Dates
using Pkg
Pkg.gc(collect_delay=Day(0))
5 Likes