What is closed module?

I have a package named MyPkg, which depends on MyPkg2. When I load MyPkg, I get the following error:

julia> using MyPkg
[ Info: Precompiling MyPkg [<MyPkg uuid>]
ERROR: LoadError: Evaluation into the closed module `MyPkg2` breaks incremental compilation because the side effects will not be permanent. This is likely due to some other module mutating `MyPkg2` with `eval` during precompilation - don't do this.

I tried to construct a MWE reproducing this error, but packages defined in REPL don’t seem to produce this error.

This makes me question the meaning of “closed module” in the error message: does it refer to a module defined as a package, compared to a module defined in REPL?

So that is likely what is happening. Some package is doing eval(MyPkg2, ...) while it is being precompiled.

I know eval is producing the error. I am trying to update the package such that it achieves the desired functionality without producing this error. For that, I was trying to reproduce the same error by modules defined in REPL that have similar structures as my packages. Once I have the modules producing the same error, I would be able to tweak the modules until I remove the error.

However, I am not able to produce the same error by the modules defined in REPL. (The reported error message is from packages.) So, I was wondering if this is because my modules in REPL are too simplified to mimic the behaviors of the packages, or because the modules defined in REPL are not “closed modules” that the error message is mentioning. If the latter is the case, I would never be able to reproduce the error by modules defined in REPL, so my attempt to find the solution to the error by tweaking modules defined in REPL will be in vain.

I think that is the important part. Your modules in the REPL are presumably not getting precompiled.

That’s a good point. Then do you think the term “closed module” does not bear any particular technical meaning?