Julia folder size

Can I ask why ~/.julia folder keeps on growing in size? I need to remove the ~/.julia folder and reinstall everything once in a while, to keep a small footprint… currently the folder is over 2.8G for 57 packages… whereas reinstalling everything fresh takes 1.7G. and what are the possible ways to trim other than reinstall all packages?

When you update a package, Julia keeps around the old version in case that particular version is needed in the future as a dependency to another package.

Additionally, if you use multiple environments for different projects, the different environments may require different versions of a particular package. So in that case, if you delete your .julia directory and only reinstall packages for the main environment, you might not have the necessary versions for your other environments.

You can garbage collect all packages that are no longer used by any of your environments by using the gc command in the Pkg REPL:

(@v1.6) pkg> gc --all
3 Likes

I tried the gc function, but missed the --all flag. Thanks

if you delete your .julia directory and only reinstall packages for the main environment

so the project.toml also resides in the .julia/enviroments rather than the project folder?

There doesn’t seem to be any duplication of project-level Project.toml files in the .julia/environments folder, so I’m not sure how gc figures that out… I don’t see that information elsewhere in the .julia directory, but it might be hidden somewhere…

Check out .julia/logs:

❯ ls ~/.julia/logs
artifact_usage.toml	orphaned.toml		scratch_usage.toml
manifest_usage.toml	repl_history.jl

manifest_usage.toml has got a huge list of manifests + timestamps, so that Pkg.gc can know which ones are old to possibly clean up.

3 Likes