# Precompile custom module fails but program still working

**URL:** <https://discourse.julialang.org/t/precompile-custom-module-fails-but-program-still-working/27859>\
**Category:** New to Julia\
**Tags:** module\
**Created:** [August 22, 2019, 4:34pm UTC](https://discourse.julialang.org/t/precompile-custom-module-fails-but-program-still-working/27859 "2019-08-22T16:34:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![wpkzz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wpkzz/32/9892_2.png) [@wpkzz](https://discourse.julialang.org/u/wpkzz)\
**Post date:** [August 22, 2019, 4:34pm UTC](https://discourse.julialang.org/t/precompile-custom-module-fails-but-program-still-working/27859/1 "2019-08-22T16:34:23Z")

</div>

I am trying to formalize my code in a more julian style and I have sepparated a lot of routines from a Jupyter Notebook to a Julia sort of script with all that I could put on a functions module in another file. I am also using another custom module that I created for solving another problem in the past. This older module is called by one of the new modules only. In the header of the new module I have something equivalent to these instructions:

```julia
push!(LOAD_PATH, "../TheOtherProblem/")
using ArrayToSetTools # my older module

```

In the main file also I have the `push!` part, but I guess is superfluous as I don’t really call anything from the other directory here.

When I ran the program with the standar `julia main.jl args` it takes some 20 seconds to start giving messages and then I get these:

```julia
┌ Warning: The call to compilecache failed to create a usable precompiled cache file for Aglomerar [top-level]
│ exception = Required dependency ArraySetTools [top-level] failed to load from a cache file.
└ @ Base loading.jl:969
┌ Warning: The call to compilecache failed to create a usable precompiled cache file for AglomeraAuxiliar [top-level]
│ exception = Required dependency ArraySetTools [top-level] failed to load from a cache file.
└ @ Base loading.jl:969
┌ Warning: The call to compilecache failed to create a usable precompiled cache file for Aglomerar [top-level]
│ exception = Required dependency ArraySetTools [top-level] failed to load from a cache file.
└ @ Base loading.jl:969

```

This takes around 3 minutes every time. Its allways the `ArraySetTools` module that is on the other directory the one that seems to generate the mess.

As I am testing continously the code with different parameters, its very tedious, and I do not seem to grasp what is wrong… ¿could it be that Julia needs to have all the code in the same directory by some reason?

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [August 22, 2019, 5:19pm UTC](https://discourse.julialang.org/t/precompile-custom-module-fails-but-program-still-working/27859/2 "2019-08-22T17:19:44Z")

</div>

Why are you mucking around with `LOAD_PATH`? I would suggest just creating packages and using the package manager.

---

<div class="post-metadata">

**Author:** ![doomphoenix-qxz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/doomphoenix-qxz/32/7009_2.png) [@doomphoenix-qxz](https://discourse.julialang.org/u/doomphoenix-qxz)\
**Post date:** [August 22, 2019, 6:04pm UTC](https://discourse.julialang.org/t/precompile-custom-module-fails-but-program-still-working/27859/3 "2019-08-22T18:04:42Z")

</div>

Wpkzz, I don’t know what your background is, but when I started using Julia after having done quite a bit with Python+numpy, code organization was a difficult thing for me. Some people here love Julia but have that one feature that they miss from Python; my missed feature is that the Python `import` keyword Just Works almost no matter how you use it. Julia’s takes a little more time to get used to and has some issues; ex. [https://github.com/JuliaLang/julia/issues/4600](https://github.com/JuliaLang/julia/issues/4600).

If you make your code into a package, as Kristoffer suggested, all of the worries about the import and using keywords go away and `using ArrayToSetTools` will do exactly what you expect. You can probably just do `] dev ArrayToSetTools` and copy your code to the `ArrayToSetTools.jl` file created in `.julia/dev/ArrayToSetTools`

---

<div class="post-metadata">

**Author:** ![wpkzz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wpkzz/32/9892_2.png) [@wpkzz](https://discourse.julialang.org/u/wpkzz)\
**Post date:** [August 22, 2019, 6:09pm UTC](https://discourse.julialang.org/t/precompile-custom-module-fails-but-program-still-working/27859/4 "2019-08-22T18:09:43Z")

</div>

Okey, I have absolutely no idea what you are talking about… Is it not, then, ordering the code in modules essentially preparing a Package? Or what is “creating a package”? Also I forgot to mention this: in my unordered code in a Jupyter Notebook I have not this issue, I can simply extend the path and load the older module in less than a second and it flows. But then the code has all the definition of functions inside and, to my taste, is like a scrapbook or the like.

---

<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:** [August 23, 2019, 4:51am UTC](https://discourse.julialang.org/t/precompile-custom-module-fails-but-program-still-working/27859/5 "2019-08-23T04:51:25Z")

</div>

> [@wpkzz](#):
>
> Is it not, then, ordering the code in modules essentially preparing a Package?

No, modules are just namespaces (but packages do use modules).

[https://docs.julialang.org/en/latest/manual/modules/](https://docs.julialang.org/en/latest/manual/modules/)

> [@wpkzz](#):
>
> what is “creating a package”

[https://julialang.github.io/Pkg.jl/dev/creating-packages/](https://julialang.github.io/Pkg.jl/dev/creating-packages/)

but I would recommend reading the whole manual from the beginning

---

<div class="post-metadata">

**Author:** ![wpkzz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wpkzz/32/9892_2.png) [@wpkzz](https://discourse.julialang.org/u/wpkzz)\
**Post date:** [August 23, 2019, 5:44pm UTC](https://discourse.julialang.org/t/precompile-custom-module-fails-but-program-still-working/27859/6 "2019-08-23T17:44:58Z")

</div>

I still find it very weird that on Jupyter I have no such issue but in the standalone script i do.
