Why almost all package be re-precompiling after a new package installed?

Hi Julia-ers,

I found that adding a new package in Julia can be quite troublesome. Each time I do this, there will be also a long precompilation process that involves almost all the packages in the current project environment, which takes a lot of time. How can I better understand this behavior or take some steps to improve it?

Hey @tiZ!

From what I understand, each package you add comes with its own set of dependencies and compatibility requirements. So when you have an environment with packages A, B and C, here’s what may happen when adding D:

  • D is a dependency of A, in which case D was already in your environment but possibly in a different version (say D1), so installing D2 will trigger recompilation of A with this new dependency
  • A is a dependency or D but D needs a different version, say A2, so installing D will remove A1 and install + precompile A2
  • D and A share a common dependency E but D is more restrictive on the version, and again you have a similar outcome

I think the main answer is that you should use separate environments for each project, with as few packages as possible in each one. If you only work in your default Julia environment v1.8 and put everything there, you will face incredibly long compilation times needlessly.
See the documentation of Pkg.jl for more details: 1. Introduction · Pkg.jl

1 Like

There is also apparently an issue with jll packages, which can subvert the default behavior that tries to keep packages to their current version: Feature request: support version numbers with build metadata · Issue #1568 · JuliaLang/Pkg.jl · GitHub