OxygenFramework/Oxygen.jl

LoadError: Evaluation into the closed module `ServerUtil` breaks incremental compilation because the side effects will not be permanent

Closed this issue · 10 comments

Hi, I'd appreciate a hint on this:

In an empty project, just after adding two deps: ] add Oxygen and ] add HTTP, I'm getting this error:

(Status) pkg> precompile
Precompiling project...
  ✗ Status
  0 dependencies successfully precompiled in 1 seconds (9 already precompiled)

ERROR: The following 1 direct dependency failed to precompile:

Status [098780a1-d72d-4c46-bf31-21b940cb7ff4]

Failed to precompile Status [098780a1-d72d-4c46-bf31-21b940cb7ff4] to /Users/adaszko/.julia/compiled/v1.7/Status/jl_d7ZoK3.
ERROR: LoadError: Evaluation into the closed module `ServerUtil` breaks incremental compilation because the side effects will not be permanent. This is likely due to some other module mutating `ServerUtil` with `eval` during precompilation - don't do this.
Stacktrace:
  [1] eval
    @ ./boot.jl:373 [inlined]
  [2] eval(x::Vector{String})
    @ Oxygen.ServerUtil ~/.julia/packages/Oxygen/l8GuF/src/serverutil.jl:1
  [3] macro expansion
    @ ~/.julia/packages/Oxygen/l8GuF/src/serverutil.jl:186 [inlined]
  [4] top-level scope
    @ ~/.julia/packages/Oxygen/l8GuF/src/Oxygen.jl:26
  [5] include
    @ ./Base.jl:418 [inlined]
  [6] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
    @ Base ./loading.jl:1318
  [7] top-level scope
    @ none:1
  [8] eval
    @ ./boot.jl:373 [inlined]
  [9] eval(x::Expr)
    @ Base.MainInclude ./client.jl:453
 [10] top-level scope
    @ none:1
in expression starting at /Users/adaszko/repos/status-julia/Status/src/Status.jl:1

Hi @adaszko,
Thanks for reporting this issue! Could you give me more details about your setup like OS & julia version. I have access to linux, mac and windows environments to test things on. I personally haven't run into this issue when setting up blank projects.

This issue stems from the way I wrote the @route & static filehosting macros. Using eval inside a macro doesn't follow best practice's but since these macros only get evaluated once on startup, I decided to leave it in because it worked. I planned on replacing those calls after adding more 'functional' features to the framework.

Sure thing: It's a M1 MacBookPro running macOS Monterey and julia version 1.7.3. Let me know if you need more details on anything

Funny enough, we have the EXACT same laptop & setup. Unfortunately, I'm having trouble replicating this issue. I don't want to leave you hanging though, is there anything else you're doing during your project setup you left out? If not I'm down to hop in a call and look at this together

I am having the same error since this morning - julia 1.7.3 on Win64. Any idea how i can resolve this?

@adaszko & @kn-markovtech
I know this is on a Mac, but does this look like the same process you all are following? (Trying opening this video with vlc media player on windows)
https://user-images.githubusercontent.com/22534471/179999761-045337e4-3427-467a-81f0-133989ff85b1.mov

@kn-markovtech
Thanks for that gif & source code.

I can now reproduce the issue from my end. Until I patch the underlying issue, you can still run the server - you just can't precompile your code. Just add a serve() call inside the OxyGDemo.jl file and call include("src\\OxyGDemo.jl") from the repl to run the server.

You can view the autogenerated docs here: http://127.0.0.1:8080/docs

@kn-markovtech @adaszko
Just to summarize, both of you should be able to run your web servers without running into this issue. Just remember that the 'precompile' command won't work until I fix it. In the meantime, let me know if either of you is not able to start the server.

A quick fix would be to disable precompile of the serverutil.jl
__precompile__(false)

https://docs.julialang.org/en/v1/manual/modules/#Module-initialization-and-precompilation

@kn-markovtech thanks for the idea, that'd be a great stopgap solution