How to keep Julia dependencies precompiled between terminal sessions?

Hello everyone,

I’m developing a Julia-based simulation model that runs from the terminal (no UI). Each time I execute the script, it precompiles all dependencies, which takes quite a long time (around 8 minutes).

Is there a way to keep installed dependencies (e.g., JuMP, Agents) precompiled and cached so that subsequent runs only compile my own modules, rather than recompiling all packages each time? Ideally, I’d like behavior similar to running code from VS Code, where even between sessions it does not recompile everything only the custom modules.

Since I’m also writing my own code. From my side, I observe it appears that only if I had modified some modules would julia re-compile, e.g.

julia> using EM, EM.In
Precompiling EM finished.
  1 dependency successfully precompiled in 4 seconds. 52 already precompiled.

Odd, precompile caching is the default behavior and it is usually only overwhelmed by frequent-enough environment switching. Just to check our terminology here, are you seeing a Precompiling printout each session?

In my experience, frequent precompilation has often to do with code loading from shared environments before activating the actual environment (for example when you load Revise in your startup and activate the env within your script). See also