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

using Pluto load error when repl started with PackageCompiler.jl sysimage #2224

Closed
a2k42 opened this issue Jul 22, 2022 · 3 comments
Closed

Comments

@a2k42
Copy link

a2k42 commented Jul 22, 2022

Julia Version 1.7.3
Pluto Version 0.19.9
OS Linux/Ubuntu 22.04

I followed the PackageCompiler.jl example for creating a sys_image.so with Plots.jl. This worked without errors.

When starting julia -J ~/.julia/sys_image.so, activating a project with Pluto and calling using Pluto I get the following errors

julia> using Pluto
[ Info: Precompiling Pluto [c3e4b0f8-55cb-11ea-2926-15256bba5781]
ERROR: LoadError: UndefVarError: @register not defined
Stacktrace:
 [1] include(mod::Module, _path::String)
   @ Base ./Base.jl:418
 [2] include(x::String)
   @ Pluto ~/.julia/packages/Pluto/9zGI7/src/Pluto.jl:11
 [3] top-level scope
   @ ~/.julia/packages/Pluto/9zGI7/src/Pluto.jl:82
 [4] include
   @ ./Base.jl:418 [inlined]
 [5] 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
 [6] top-level scope
   @ none:1
 [7] eval
   @ ./boot.jl:373 [inlined]
 [8] eval(x::Expr)
   @ Base.MainInclude ./client.jl:453
 [9] top-level scope
   @ none:1
in expression starting at /home/andy/.julia/packages/Pluto/9zGI7/src/webserver/Static.jl:161
in expression starting at /home/andy/.julia/packages/Pluto/9zGI7/src/webserver/Static.jl:118
in expression starting at /home/andy/.julia/packages/Pluto/9zGI7/src/Pluto.jl:1
ERROR: Failed to precompile Pluto [c3e4b0f8-55cb-11ea-2926-15256bba5781] to /home/andy/.julia/compiled/v1.7/Pluto/jl_cApCbv.
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, ignore_loaded_modules::Bool)
   @ Base ./loading.jl:1466
 [3] compilecache(pkg::Base.PkgId, path::String)
   @ Base ./loading.jl:1410
 [4] _require(pkg::Base.PkgId)
   @ Base ./loading.jl:1120
 [5] require(uuidkey::Base.PkgId)
   @ Base ./loading.jl:1013
 [6] require(into::Module, mod::Symbol)
   @ Base ./loading.jl:997

To keep things simple I used a temp environment so that Pluto and the sys_image.so were the only things loaded

activate --temp

add Pluto

For reference, I created the sys_image.so with

using PackageCompiler

create_sysimage(["Plots"], sysimage_path="~/.julia/sys_image.so", precompile_execution_file="precompile_plots.jl")
# precompile_plots.jl
using Plots
p = plot(rand(2, 2))
display(p)

As a further test I tried adding Luxor.jl and then using Luxor, which was fine. Pluto works normally when starting julia without an image.

Not sure if this is related to #1937 at all?

Bit of a noob, so apologies in advanced if this is a failure of my understanding.

@rikhuijzer
Copy link
Collaborator

rikhuijzer commented Jul 22, 2022

Does the sysimage or your global environment contain HTTP version 1 or above? @register was removed from HTTP in version 1. Pluto still uses the older HTTP version so that would explain why @register cannot be found anymore. The new HTTP version is on its way to be released for Pluto (#2185) by the way.

Note that packages defined in a higher level of the environment will always persist inside Julia even if lower-level packages indicate that they don't work with the earlier defined package. This is a known bug (JuliaLang/julia#36372).

@rikhuijzer
Copy link
Collaborator

Based on the fact that your issue is at using Pluto and that your sysimage only contains Plots.jl, I bet that you have HTTP.jl in your global environment. You can check this by starting Julia and doing

pkg> st
[...]

If that is the case, then I would advice to be more selective in deciding what you install in the global environment. In my case, the global environment contains only BenchmarkTools, Revise, TestEnv, PProf and Pluto. These are all more app's than packages. For the rest, use separate environments via

pkg> activate --temp
[...]

or

pkg> activate <some_folder_or_package>
[...]

Given that this issue appears to not be Pluto related, I'll close it. Feel free to reopen if my bet is wrong and you do not have HTTP version 1 or higher installed in your global environment.

@a2k42
Copy link
Author

a2k42 commented Jul 22, 2022

Thanks for the info.

My global environment is sparse with only:

(@v1.7) pkg> st
      Status `~/.julia/environments/v1.7/Project.toml`
  [6e4b80f9] BenchmarkTools v1.3.1
  [295af30f] Revise v3.3.3

However, when I use st -m I can see that my sys_image.so has HTTP v1.2.0 included as a dependency. The PackageCompiler.jl manual states:

The biggest drawback is that packages that are compiled into a sysimage (including their dependencies!) are "locked" to the version they were at when the sysimage was created.

So, it would indeed appear that this is the problem. Thanks again, I'll consider this something to workaround until #2185 is complete.

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

No branches or pull requests

2 participants