# What triggers precompiling?

**URL:** <https://discourse.julialang.org/t/what-triggers-precompiling/38878>\
**Category:** General Usage\
**Created:** [May 6, 2020, 10:44am UTC](https://discourse.julialang.org/t/what-triggers-precompiling/38878 "2020-05-06T10:44:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![HenriDeh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrideh/32/8316_2.png) [@HenriDeh](https://discourse.julialang.org/u/HenriDeh)\
**Post date:** [May 6, 2020, 10:44am UTC](https://discourse.julialang.org/t/what-triggers-precompiling/38878/1 "2020-05-06T10:44:52Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [May 6, 2020, 12:11pm UTC](https://discourse.julialang.org/t/what-triggers-precompiling/38878/2 "2020-05-06T12:11:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [May 6, 2020, 2:17pm UTC](https://discourse.julialang.org/t/what-triggers-precompiling/38878/3 "2020-05-06T14:17:24Z")

</div>

> [@fredrikekre](#):
>
> It could be that one of the dependencies was updated

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.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [May 6, 2020, 4:15pm UTC](https://discourse.julialang.org/t/what-triggers-precompiling/38878/4 "2020-05-06T16:15:43Z")

</div>

Only if it is the [10th](https://github.com/JuliaLang/julia/blob/99dbd2dda437244780206b3da1d9282c09616a94/base/loading.jl#L1254) project. For example these three projects does not recompile:

```bash
$ 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

$

```

---

<div class="post-metadata">

**Author:** ![HenriDeh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrideh/32/8316_2.png) [@HenriDeh](https://discourse.julialang.org/u/HenriDeh)\
**Post date:** [May 6, 2020, 6:37pm UTC](https://discourse.julialang.org/t/what-triggers-precompiling/38878/5 "2020-05-06T18:37:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [May 6, 2020, 6:44pm UTC](https://discourse.julialang.org/t/what-triggers-precompiling/38878/6 "2020-05-06T18:44:34Z")

</div>

> [@fredrikekre](#):
>
> Only if it is the [10th](https://github.com/JuliaLang/julia/blob/99dbd2dda437244780206b3da1d9282c09616a94/base/loading.jl#L1254) project

Thanks for the clarification
