# How to re-trigger pre-compilation

**URL:** <https://discourse.julialang.org/t/how-to-re-trigger-pre-compilation/62156>\
**Category:** General Usage\
**Tags:** question\
**Created:** [May 31, 2021, 10:16pm UTC](https://discourse.julialang.org/t/how-to-re-trigger-pre-compilation/62156 "2021-05-31T22:16:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [May 31, 2021, 10:16pm UTC](https://discourse.julialang.org/t/how-to-re-trigger-pre-compilation/62156/1 "2021-05-31T22:16:19Z")

</div>

Hello,

I need to re-create the .ji files of my user modules  
each time I updated my custom sys image.

I am using a script to create the custom sys image and  
I suggest the users of my software to run it again each  
time the have pulled a new software version.

If the sys image has changed, but the source code of  
my user modules did not change, the compiled .ji files  
do not work any more and the startup time of my app  
is way higher then normal.

So I want to automatically re-create the .ji files  
at the end of the script that creates the user image.

This is easy on Linux:

rm -rf ~/.julia/compiled/v1.6/\*.ji

as long as you know the julia version, but it will not  
work for example on Windows.

Is there better way to force the re-creation of the .ji  
files for user modules?

Uwe

---

<div class="post-metadata">

**Author:** ![ptoche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ptoche/32/23554_2.png) [@ptoche](https://discourse.julialang.org/u/ptoche)\
**Post date:** [May 31, 2021, 10:44pm UTC](https://discourse.julialang.org/t/how-to-re-trigger-pre-compilation/62156/2 "2021-05-31T22:44:10Z")

</div>

would it work to condition on the OS ? See [here](https://docs.julialang.org/en/v1/manual/handling-operating-system-variation/).

```julia
if Sys.iswindows()
    windows_specific_thing(a)
end

```

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [May 31, 2021, 10:57pm UTC](https://discourse.julialang.org/t/how-to-re-trigger-pre-compilation/62156/3 "2021-05-31T22:57:55Z")

</div>

I have no idea where .ji files are stored on Windows…

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [June 1, 2021, 6:19am UTC](https://discourse.julialang.org/t/how-to-re-trigger-pre-compilation/62156/4 "2021-06-01T06:19:23Z")

</div>

There must be a mechanism in Julia base that allows to invalidate a module, because this happens automatically when you change its source code and re-load it. How can I trigger this mechanism manually?

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [June 1, 2021, 11:34am UTC](https://discourse.julialang.org/t/how-to-re-trigger-pre-compilation/62156/5 "2021-06-01T11:34:45Z")

</div>

I have this function that when run will force pre-compilation on next fresh julia session. It’s meant for a single package but you can extend it for more.

```julia
force_precompile() = Sys.iswindows() ? run(`cmd /c copy /b "$(pathof(GMT))" +,, "$(pathof(GMT))"`) : run(`touch '$(pathof(GMT))'`)

```

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [June 1, 2021, 8:39pm UTC](https://discourse.julialang.org/t/how-to-re-trigger-pre-compilation/62156/6 "2021-06-01T20:39:53Z")

</div>

Well, the `touch` command is also available on Linux. So I use the following lines now in my script that creates a new system image to force pre-compilation of the user modules:

```julia
cd src
touch *.jl # make sure all modules get recompiled in the next step
cd ..
julia --project -J MakieSys.so -e "push!(LOAD_PATH,joinpath(pwd(),\"src\"));using Utils, KCU_Sim, KPS3, Plot2D, RTSim"

```

This should also work on git-bash which I use on Windows.
