What triggers precompiling?

Sometimes I use a package with using ThePackage and it precompiles even if it was not updated since the last use, nor was Julia. Is there something I’m doing wrong such that precompiling is so often needed ?

It could be that one of the dependencies was updated. Or that the precompile file was deleted.

4 Likes

AFAIU, one case that subtly falls in this category is when you use ThePackage in two different environments.

The first time, ThePackage is pre-compiled for the set of dependencies specified in the first environment. If you subsequently use the same package in a second environment where some of the dependencies have changed version for some reason (possibly related to an other, entirely separate package that happens to have dependencies in common), then ThePackage has to be recompiled for this different set of dependencies.

1 Like

Only if it is the 10th project. For example these three projects does not recompile:

$ rm -rf ~/.julia/compiled/

$ for i in 0 1 2; do pkg --project=project-${i} add JSON Parsers@1.0.${i}; done
[...]

$ for i in 0 1 2; do julia --project=project-${i} -iqe 'using JSON; exit()'; done
[ Info: Precompiling JSON [682c06a0-de6a-54ab-a142-c8b1cf79cde6]
[ Info: Precompiling JSON [682c06a0-de6a-54ab-a142-c8b1cf79cde6]
[ Info: Precompiling JSON [682c06a0-de6a-54ab-a142-c8b1cf79cde6]

$ for i in 0 1 2; do julia --project=project-${i} -iqe 'using JSON; exit()'; done

$
4 Likes

Ha yes, I switch environments quite often. That would explain it thank you.

Thanks for the clarification