What can I remove from /.julia?

I am trying to build a slim docker image to run an app. I’m using PackageCompiler.jl to build a sysimage (using filter_stdlibs).

I’d like to remove unnecessary files from the .julia file to slim even more. I feel pretty safe removing share/doc and share/julia/test directories, but is there anything else?

  1. Can I remove the original sysimage shipped with Julia? If so, am I right to assume that it is saved at lib/julia/libjulia.so?
  2. Can I delete stdlib directories from juila/compiled/v1.10/ that I’m confident I’m not using?
  3. How about the stdlib source code?

You can pretty safely delete the entire folder, except maybe the dev subfolder, which may have packages that you’ve installed via ] dev.

On that note, I generally recommend against using dev to clone packages into your ~/.julia/dev folder. Instead, clone them first to a better location, using git, and then dev-install them with ] dev <folder>. If you do that, there should be no problem at all with deleting ~/.julia. It will be re-created the next time your run Julia.

How could it be that I can delete the whole thing? To use the system image, you need to run julia --sysimage /path/to/sysimage.so. So If I delete the whole thing, I won’t have an executable to run the system image. Or maybe I’m missing something?

You don’t have to run julia with any flags. The --sysimage flag is for when you’ve created a custom system image manually (which, personally, I’ve only ever done once, to potentially speed up the time-to-first-x for a simulation on an HPC cluster).

I’ve definitely deleted my ~/.julia folder on many occasions, and it doesn’t affect Julia at all. Except of course that you have to re-install and re-compile all the packages that you’ve had in your base environment. In fact, that’s how people usually clean up their base environment if they’ve made the mistake of installing too many packages in there, instead of doing proper project environments.

Apart from dev, if you’ve manually made “unsaved” changes in the folder, there’s nothing in ~/.julia that can’t be easily recreated. It’s basically a cache folder.

Maybe just keep a copy of your .julia/config/startup.jl

1 Like

Okay, I figured out the confusion – my installation of juliaup installs versions of Julia inside the .julia folder. So if I were to delete .julia, it would also delete the Julia executable. I asked about the .julia directory because I thought I was referring to “the place where the Julia executable and its dependencies live.”

So, to go back and ask this question correctly –

What can I delete from the julia (no leading period) directory where Base, stdlib, etc. are stored?

  • I know I can delete test and docs and Julia will still run.
  • Since I have compiled a custom sysimage, I think I can delete the original sysimage, but I’m not sure where that lives.
  • I was hoping to delete the compiled binaries that are used by stdlib package I’m not using. Would that cause issue for Julia trying to start?
  • Anything else?