panifie / PingPong.jl

Cryptocurrency trading bot, and backtesting framework in julia
https://panifie.github.io/PingPong.jl/
GNU General Public License v3.0
36 stars 9 forks source link

ERROR: LoadError: InitError: Evaluation into the closed module `PingPong` breaks incremental compilation because the side effects will not be permanent. #52

Closed janckerchen closed 1 week ago

janckerchen commented 1 week ago

pull last commit and test SimpleStrategy failed.

julia> @environment!

julia> s = st.strategy(:SimpleStrategy, exchange=:binance)

Precompiling SimpleStrategy
        Info Given SimpleStrategy was explicitly requested, output will be shown live
ERROR: LoadError: InitError: Evaluation into the closed module `PingPong` breaks incremental compilation because the side effects will not be permanent. This is likely due to some other module mutating `PingPong` with `eval` during precompilation - don't do this.
Stacktrace:
  [1] eval
    @ ./boot.jl:385 [inlined]
  [2] __init__()
    @ PingPong /opt/opensource/jl/PingPong.jl/PingPong/src/PingPong.jl:6
  [3] run_module_init(mod::Module, i::Int64)
    @ Base ./loading.jl:1134
  [4] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1122
  [5] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
    @ Base ./loading.jl:1067
  [6] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
janckerchen commented 1 week ago

After recloning the entire project and recompiling, the issue disappeared—very strange.

panbonker commented 1 week ago

this can happen if you loaded julia with env vars different from when precompilation was done specifically the env var: JULIA_NOPRECOMP # these modules code is evaluated (eval) at runtime, ensure it's empty

Another possible cause is the fact that SimpleStrategy uses default_load which calls invokelatest https://github.com/panifie/PingPong.jl/blob/3326d57cc8b8fcaeb66e5fc8b2d1c6a5342837dd/Strategies/src/load.jl#L136 don't remember if invokelatest is actually necessary here

janckerchen commented 1 week ago

I did change JULIA_NOPRECOMP, maybe after revert the code, I didn't restart vscode and .envrc didn't take effect again (you need to start with code . from the terminal in order to inherit the .envrc environment variable in vscode)