Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Backend init broken in Julia 1.10 if loaded during precompilation #4865

Closed
BioTurboNick opened this issue Jan 10, 2024 · 2 comments · Fixed by #4870
Closed

[BUG] Backend init broken in Julia 1.10 if loaded during precompilation #4865

BioTurboNick opened this issue Jan 10, 2024 · 2 comments · Fixed by #4870
Labels

Comments

@BioTurboNick
Copy link
Member

https://github.com/JuliaPlots/Plots.jl/blob/0d956739d57d87b7557649aaf4948fcf24fb60d4/src/backends.jl#L396C1-L409C4

function _initialize_backend(pkg::AbstractBackend)
    _pre_imports(pkg)
    name = backend_package_name(pkg)
    # NOTE: this is a hack importing in `Main` (expecting the package to be in `Project.toml`, remove in `[email protected]`)
    # FIXME: remove hard `GR` dependency in `[email protected]`
    @eval name === :GR ? Plots : Main begin
        import $name
        export $name
        $(_check_compat)($name)
    end
    _post_imports(pkg)
    _runtime_init(pkg)
    nothing
end

Causes issues like this in CI: https://github.com/JuliaPlots/Plots.jl/actions/runs/7443223127/job/20247799581

ERROR: LoadError: Creating a new global in closed module `Main` (`UnicodePlots`) breaks incremental compilation because the side effects will not be permanent.
Stacktrace:
  [1] top-level scope
    @ ~/work/Plots.jl/Plots.jl/src/backends.jl:402
  [2] eval
    @ Core ./boot.jl:385 [inlined]
  [3] _initialize_backend(pkg::Plots.UnicodePlotsBackend)
    @ Plots ~/work/Plots.jl/Plots.jl/src/backends.jl:401
  [4] backend(pkg::Plots.UnicodePlotsBackend)
    @ Plots ~/work/Plots.jl/Plots.jl/src/backends.jl:266

But can also occur in other scenarios: JuliaPlots/PlotlyJS.jl#478

@BioTurboNick
Copy link
Member Author

Guess this was known, a shame it hasn't been addressed: JuliaLang/julia#51117

@BeastyBlacksmith
Copy link
Member

I think the course of action here, is to release a new point version that removes the precompilation of non-GR default backends on 1.10+ and then go full package extensions in 2.0 ( xref: #4565 ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants