# Is it correct that it recompiles packages every time a new REPL is opened?

**URL:** https://discourse.julialang.org/t/is-it-correct-that-it-recompiles-packages-every-time-a-new-repl-is-opened/30266
**Category:** New to Julia
**Tags:** question
**Created:** [October 24, 2019, 12:21pm UTC](https://discourse.julialang.org/t/is-it-correct-that-it-recompiles-packages-every-time-a-new-repl-is-opened/30266 "2019-10-24T12:21:37Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Nycto](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nycto/32/10972_2.png) [@Nycto](https://discourse.julialang.org/u/Nycto)
#### Post date: [October 24, 2019, 12:21pm UTC](https://discourse.julialang.org/t/is-it-correct-that-it-recompiles-packages-every-time-a-new-repl-is-opened/30266/1 "2019-10-24T12:21:37Z")

</div>

E.g. the first time you use plots.jl after opening a new REPL it has to recompile. I was thinking that since the code is unchanged, shouldn’t it just use the old compiled version? Is it going to always recompile, or is there something about the dependencies for plots.jl that it thinks the version it compiled 20 minutes ago is out of date? Is there some way I can have a chunk of code that doesn’t recompile with every new REPL I open, and only recompile the sub-module I’m currently developing?

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [October 24, 2019, 12:36pm UTC](https://discourse.julialang.org/t/is-it-correct-that-it-recompiles-packages-every-time-a-new-repl-is-opened/30266/2 "2019-10-24T12:36:18Z")

</div>

There are two things going on that might give you a noticable lag:

1. [precompilation](https://docs.julialang.org/en/v1.4-dev/manual/modules/#Module-initialization-and-precompilation-1), which results in a lag when you just load packages (eg `using Something`). This is cached, with improvements in 1.3 (eg if you `pkg> activate` different environments).

2. AOT compilation, when you call a function with given types for the first time. This information is lost every time you restart — there are workarounds, but they are work in progress.

Also, are you aware of

> **[GitHub - timholy/Revise.jl: Automatically update function definitions in a...](https://github.com/timholy/Revise.jl)**
>
> Automatically update function definitions in a running Julia session - GitHub - timholy/Revise.jl: Automatically update function definitions in a running Julia session

? Most Julia users use it to alleviate the necessity to restart so often.

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [October 24, 2019, 1:51pm UTC](https://discourse.julialang.org/t/is-it-correct-that-it-recompiles-packages-every-time-a-new-repl-is-opened/30266/3 "2019-10-24T13:51:39Z")

</div>

Precompilation only happens when the package version changes. The issue with Plots is something separate.

---

<div class="post-metadata">

### Author: ![Egwene\_al\_Vere](https://avatars.discourse-cdn.com/v4/letter/e/df788c/32.png) [@Egwene\_al\_Vere](https://discourse.julialang.org/u/Egwene_al_Vere)
#### Post date: [October 24, 2019, 3:43pm UTC](https://discourse.julialang.org/t/is-it-correct-that-it-recompiles-packages-every-time-a-new-repl-is-opened/30266/4 "2019-10-24T15:43:10Z")

</div>

Additionally, you may try `compile_incremental` with PackageCompiler.jl to build the packages into a new system image you may use: [https://github.com/JuliaLang/PackageCompiler.jl](https://github.com/JuliaLang/PackageCompiler.jl)

---

<div class="post-metadata">

### Author: ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)
#### Post date: [October 24, 2019, 5:20pm UTC](https://discourse.julialang.org/t/is-it-correct-that-it-recompiles-packages-every-time-a-new-repl-is-opened/30266/5 "2019-10-24T17:20:26Z")

</div>

A significant number if causes of this are fixed in julia 1.3

---

<div class="post-metadata">

### Author: ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)
#### Post date: [October 24, 2019, 5:26pm UTC](https://discourse.julialang.org/t/is-it-correct-that-it-recompiles-packages-every-time-a-new-repl-is-opened/30266/6 "2019-10-24T17:26:02Z")

</div>

> [@ChrisRackauckas](#):
>
> Precompilation only happens when the package version changes. The issue with Plots is something separate.

Packages can also get re-precompiled when used in a different environment (same version of the package), a big pain point for me when using the recommended “individual environments for different projects” workflow.

However, it’s unlikely that this is the issue here.

EDIT: To be a bit more precise, re-precompilation for Package A only happens when either A itself or one of its dependencies has a different version in the other environment. If the environments are identical then there is no re-precompilation.

---

<div class="post-metadata">

### Author: ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)
#### Post date: [October 24, 2019, 9:03pm UTC](https://discourse.julialang.org/t/is-it-correct-that-it-recompiles-packages-every-time-a-new-repl-is-opened/30266/7 "2019-10-24T21:03:05Z")

</div>

A straightforward possibility is to run a script file (`include("updatePkg.jl")`) “overnight” every now and then, which contains statements of type:

```julia
using Pkg
Pkg.update()
using Plots
using DifferentialEquations
...

```

(with `using ...` for all the packages that are big and take long time to precompile). This way, the precompilation work is done during sleep and is not noticeable.

---

<div class="post-metadata">

### Author: ![Nycto](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nycto/32/10972_2.png) [@Nycto](https://discourse.julialang.org/u/Nycto)
#### Post date: [October 24, 2019, 10:07pm UTC](https://discourse.julialang.org/t/is-it-correct-that-it-recompiles-packages-every-time-a-new-repl-is-opened/30266/9 "2019-10-24T22:07:05Z")

</div>

Ok, since I am still in the early stages of this mini-project I think I’ll just switch to the most recent 1.3. I’ve been using 1.2 as the “stable” release.

---

<div class="post-metadata">

### Author: ![Nycto](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nycto/32/10972_2.png) [@Nycto](https://discourse.julialang.org/u/Nycto)
#### Post date: [October 24, 2019, 10:11pm UTC](https://discourse.julialang.org/t/is-it-correct-that-it-recompiles-packages-every-time-a-new-repl-is-opened/30266/10 "2019-10-24T22:11:00Z")

</div>

This is a great idea. I will start using this too.

---

<div class="post-metadata">

### Author: ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)
#### Post date: [October 25, 2019, 12:17pm UTC](https://discourse.julialang.org/t/is-it-correct-that-it-recompiles-packages-every-time-a-new-repl-is-opened/30266/11 "2019-10-25T12:17:08Z")

</div>

Not really a great idea; rather a trivial idea – and I’m sure many others do the same. But I like to make the computer work while I sleep…

---

<div class="post-metadata">

### Author: ![bjarthur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bjarthur/32/9638_2.png) [@bjarthur](https://discourse.julialang.org/u/bjarthur)
#### Post date: [July 27, 2020, 10:23pm UTC](https://discourse.julialang.org/t/is-it-correct-that-it-recompiles-packages-every-time-a-new-repl-is-opened/30266/12 "2020-07-27T22:23:31Z")

</div>

there is a [bug](https://github.com/JuliaLang/Pkg.jl/issues/1578) in `precompile`. perhaps that’s the problem with Plots here?

also, tamas\_papp— you meant JIT i think, not AOT.
